Explain how you would manage memory allocation and prevent leaks in a resource-constrained environment.