memory-leaks

Find all references to an object in python

Find all references to an object in python Question: What is a good way to find all of the references to an object in python? The reason I ask is that it looks like we have a “memory leak”. We are uploading image files to the server from a web browser. Each time we do …

Total answers: 2

How can I release memory after creating matplotlib figures

How can I release memory after creating matplotlib figures Question: I have several matlpotlib functions rolled into some django-celery tasks. Every time the tasks are called more RAM is dedicated to python. Before too long, python is taking up all of the RAM. QUESTION: How can I release this memory? UPDATE 2 – A Second …

Total answers: 2

Python: memory usage statistics per object-types (or source code line)

Python: memory usage statistics per object-types (or source code line) Question: I am doing some heavy calculations with Python (using OpenCV and Numpy) and in the end, I end up with a lot of memory usage (>1GB) whereby all refs should be gone and I only have the end-result (which should not be more than …

Total answers: 2

Unload a module in Python

Unload a module in Python Question: TL/DR: import gc, sys print len(gc.get_objects()) # 4073 objects in memory # Attempt to unload the module import httplib del sys.modules[“httplib”] httplib = None gc.collect() print len(gc.get_objects()) # 6745 objects in memory UPDATE I’ve contacted Python developers about this problem and indeed it’s not going to be possible to …

Total answers: 5

Django memory usage going up with every request

Django memory usage going up with every request Question: I moved my first Django project from DjangoEurope to Webfaction, and that started an issue looking like a memory leak. With every single request memory usage of the server process goes up about 500kb. It never goes down. This goes on until Webfaction kills it for …

Total answers: 8

Is it possible to have an actual memory leak in Python because of your code?

Is it possible to have an actual memory leak in Python because of your code? Question: I don’t have a code example, but I’m curious whether it’s possible to write Python code that results in essentially a memory leak. Asked By: orokusaki || Source Answers: Of course you can. The typical example of a memory …

Total answers: 6

Python – Working around memory leaks

Python – Working around memory leaks Question: I have a Python program that runs a series of experiments, with no data intended to be stored from one test to another. My code contains a memory leak which I am completely unable to find (I’ve look at the other threads on memory leaks). Due to time …

Total answers: 4

Is it normal that running python under valgrind shows many errors with memory?

Is it normal that running python under valgrind shows many errors with memory? Question: I’ve tried to debug memory crash in my Python C extension and tried to run script under valgrind. I found there is too much “noise” in the valgrind output, even if I’ve ran simple command as: valgrind python -c “” Valgrind …

Total answers: 7

Python memory leaks

Python memory leaks Question: I have a long-running script which, if let to run long enough, will consume all the memory on my system. Without going into details about the script, I have two questions: Are there any “Best Practices” to follow, which will help prevent leaks from occurring? What techniques are there to debug …

Total answers: 9

Python: Memory leak debugging

Python: Memory leak debugging Question: I have a small multithreaded script running in django and over time its starts using more and more memory. Leaving it for a full day eats about 6GB of RAM and I start to swap. Following http://www.lshift.net/blog/2008/11/14/tracing-python-memory-leaks I see this as the most common types (with only 800M of memory …

Total answers: 7