| Latest |Kites |Pictures |Programming |Life |
![]() [filed under Programming]Python memory leak detector ![]() Tags: Python, memory leak, leek, object, garbage collection, garbage collector, __del__, inspect, gc, DEBUG_LEAK I have a nasty memory leak in my Python script which I can't find. For some random projects my script gobbles up 2gig of memory then quietly dies. Here is my first attempt at cobbling together a leak detector: import gc When run it outputs: Collecting GARBAGE: As you can see it tries to figure out where the object is defined in your code. This should give you some clues as to where the leak is happening. If you are still having problems try adding some debug comments to the classes as you create them, print the debug info in the dump_garbage() function. This is based on this python memory leak detector at active state. I am learning all this as I go. I guess outputing this as a .csv would help. If you have any comments or improvements drop me a line in the comments below and I'll update the code. These are some links and stuff to help you get started hunting down your memory leak:
Update: A simple urllib2 memory leak test. Comments |
| Server Grind [0.0023 seconds] |