How do you manage memory allocation and prevent leaks in a continuous-loop computer vision application running on an embedded Linux system?