How do you manage memory and prevent leaks in long-running processes on resource-constrained hardware?