Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > memory leak troubleshooting techniques

Reply
Thread Tools

memory leak troubleshooting techniques

 
 
Adam Deutsch
Guest
Posts: n/a
 
      07-28-2003
I would like to ask some advice about tracking down memory leaks in Python
code.

We have a python application running on Python 2.0.1 in an embedded Linux
environment (kernel version 2.4.7). We have recently detected a memory leak
that we can see from "ps aux" is attributable to the Python processes.
Running Sam Rushing's (http://www.nightmare.com/medusa/memory-leaks.html)
get_refcounts() function does not yield any smoking guns: the reference
counts for all classes remain stable even as memory use climbs.

Is there any systematic method of determining how Python is using its
allocated memory?

Thanks.

 
Reply With Quote
 
 
 
 
Martin v. =?iso-8859-15?q?L=F6wis?=
Guest
Posts: n/a
 
      07-29-2003
Adam Deutsch <(E-Mail Removed)> writes:

> Is there any systematic method of determining how Python is using its
> allocated memory?


In the debug version, you can get a list of all objects through
sys.getobjects. In the non-debug version, you can get a list of all
container objects through gc.get_objects. Check whether these lists
are growing in size.

Regards,
Martin

 
Reply With Quote
 
 
 
 
Christoph Becker-Freyseng
Guest
Posts: n/a
 
      07-29-2003
Adam Deutsch wrote:
> I would like to ask some advice about tracking down memory leaks in Python
> code.
>
> We have a python application running on Python 2.0.1 in an embedded Linux
> environment (kernel version 2.4.7). We have recently detected a memory leak
> that we can see from "ps aux" is attributable to the Python processes.
> Running Sam Rushing's (http://www.nightmare.com/medusa/memory-leaks.html)
> get_refcounts() function does not yield any smoking guns: the reference
> counts for all classes remain stable even as memory use climbs.
>
> Is there any systematic method of determining how Python is using its
> allocated memory?
>
> Thanks.
>

There might be one more readon for a memory-leak -- besides an
increasing refcount.

Have you thought about a growing string? (or an similar object)
In Python a string can have 80 MB without problems / not "hurting" python.
Of course the refount won't get higher as there's just one string -- but
this one might be getting *huge*.
I had such a problem when programming PersistentThreads. Making internal
calls to the "ZopeRequestDispatcher" caused sys.path to grow.

Unfortunately I don't know a way in Python to list objects that consume
more than xy bytes of memory.


Christoph Becker-Freyseng



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Memory leak even after deleting memory pointers from vector cham C++ 5 09-25-2008 10:30 AM
per-thread memory mangement techniques for c++... Chris Thomasson C++ 0 03-03-2007 11:05 PM
Leak or no leak ?? Richard Heathfield C Programming 4 07-10-2006 11:37 AM
Dynamic memory allocation and memory leak... s.subbarayan C Programming 10 03-22-2005 02:48 PM
Memory leak??? (top reporting high memory usage under Solaris) Mark Probert Ruby 4 02-09-2005 06:13 PM



Advertisments