How to diagnose potential memory leak in Python program?

view story

http://stackoverflow.com – I have an embedded Linux system with 256MB of RAM. There is a large codebase running on it, most in C++ but some utilities are in Python. We have a Python "package manager" that handles updates to the system using the Python apt module (we distribute our updates as .deb files). When running, this application uses a large portion of the system RAM. I am monitoring RAM usage with top, looking at the RSS for the Python process (maybe this is not a valid way to analyze process memory usage? Open to suggestions). The line cache = apt.Cache() which is called periodically to check on t (HowTos)