Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Understanding memory leak reports

Reply
Thread Tools

Understanding memory leak reports

 
 
Giampaolo Rodola'
Guest
Posts: n/a
 
      12-21-2007
Hi,
I'm in a big trouble since I don't know how to find some memory leaks
I just discovered in a program of mine.
By putting:

import gc
gc.set_debug(gc.DEBUG_LEAK)

...at the end of a script which imports a module I wrote it seems I
have some memory leaks scattered around.
The message printed on screen is the following:

gc: collectable <function 00C70E70>
gc: collectable <type 00B41018>
gc: collectable <dict 00C6DE40>
gc: collectable <tuple 00C09900>
gc: collectable <tuple 00BCD510>
gc: collectable <function 00C70EB0>
gc: collectable <function 00C70E30>

Since the main module is very big (more than 2800 lines of code) I do
not understand which objects are not garbage collected.
Is there a way to have a more detailed message to know which objects
are not garbage collected?
For example "function foo", "method MyClass.bar", "dict my_dict"...
"function 00C70E70" and "tuple 00C09900" are too much generic messages
which don't give me an idea about where the leak could be.
 
Reply With Quote
 
 
 
 
kyosohma@gmail.com
Guest
Posts: n/a
 
      12-21-2007
On Dec 21, 12:44 pm, "Giampaolo Rodola'" <(E-Mail Removed)> wrote:
> Hi,
> I'm in a big trouble since I don't know how to find some memory leaks
> I just discovered in a program of mine.
> By putting:
>
> import gc
> gc.set_debug(gc.DEBUG_LEAK)
>
> ..at the end of a script which imports a module I wrote it seems I
> have some memory leaks scattered around.
> The message printed on screen is the following:
>
> gc: collectable <function 00C70E70>
> gc: collectable <type 00B41018>
> gc: collectable <dict 00C6DE40>
> gc: collectable <tuple 00C09900>
> gc: collectable <tuple 00BCD510>
> gc: collectable <function 00C70EB0>
> gc: collectable <function 00C70E30>
>
> Since the main module is very big (more than 2800 lines of code) I do
> not understand which objects are not garbage collected.
> Is there a way to have a more detailed message to know which objects
> are not garbage collected?
> For example "function foo", "method MyClass.bar", "dict my_dict"...
> "function 00C70E70" and "tuple 00C09900" are too much generic messages
> which don't give me an idea about where the leak could be.


I've never done this before, but here's what I found while Googling:

Recipe that supposedly gives more info:
http://aspn.activestate.com/ASPN/Coo...n/Recipe/65333

Another thread on the same topic that looks quite detailed:
http://www.thescripts.com/forum/thread22097.html

An article or two on memory leaks in Python:
http://utcc.utoronto.ca/~cks/space/b...honMemoryLeaks
http://www.nightmare.com/medusa/memory-leaks.html

I hope they help.

Mike
 
Reply With Quote
 
 
 
 
Giampaolo Rodola'
Guest
Posts: n/a
 
      12-21-2007
On 21 Dic, 20:10, (E-Mail Removed) wrote:
> On Dec 21, 12:44 pm, "Giampaolo Rodola'" <(E-Mail Removed)> wrote:
>
>
>
>
>
> > Hi,
> > I'm in a big trouble since I don't know how to find some memory leaks
> > I just discovered in a program of mine.
> > By putting:

>
> > import gc
> > gc.set_debug(gc.DEBUG_LEAK)

>
> > ..at the end of a script which imports a module I wrote it seems I
> > have some memory leaks scattered around.
> > The message printed on screen is the following:

>
> > gc: collectable <function 00C70E70>
> > gc: collectable <type 00B41018>
> > gc: collectable <dict 00C6DE40>
> > gc: collectable <tuple 00C09900>
> > gc: collectable <tuple 00BCD510>
> > gc: collectable <function 00C70EB0>
> > gc: collectable <function 00C70E30>

>
> > Since the main module is very big (more than 2800 lines of code) I do
> > not understand which objects are not garbage collected.
> > Is there a way to have a more detailed message to know which objects
> > are not garbage collected?
> > For example "function foo", "method MyClass.bar", "dict my_dict"...
> > "function 00C70E70" and "tuple 00C09900" are too much generic messages
> > which don't give me an idea about where the leak could be.

>
> I've never done this before, but here's what I found while Googling:
>
> Recipe that supposedly gives more info:http://aspn.activestate.com/ASPN/Coo...n/Recipe/65333
>
> Another thread on the same topic that looks quite detailed:http://www.thescripts.com/forum/thread22097.html
>
> An article or two on memory leaks in Python:http://utcc.utoronto.ca/~cks/space/b...ory-leaks.html
>
> I hope they help.
>
> Mike- Nascondi testo tra virgolette -
>
> - Mostra testo tra virgolette -


Thanks for your search but I haven't actually found a solution yet.
I've tried to search into the cookbook. I found other recipes playing
with the gc module but it seems that none of them are useful for
finding out the names of the objects causing the memory leak.
I've tried to play with gc.get_objects() in the hope to find the real
names manually but it returns a very large number of objects.
If only I could find a way to make gc.get_objects() returning leaking
objects only it would be a step forward...
Does someone have an idea about how doing such a thing?
 
Reply With Quote
 
Ross Ridge
Guest
Posts: n/a
 
      12-22-2007
Giampaolo Rodola' <(E-Mail Removed)> wrote:
>I'm in a big trouble since I don't know how to find some memory leaks

....
>The message printed on screen is the following:
>
>gc: collectable <function 00C70E70>
>gc: collectable <type 00B41018>
>gc: collectable <dict 00C6DE40>
>gc: collectable <tuple 00C09900>
>gc: collectable <tuple 00BCD510>
>gc: collectable <function 00C70EB0>
>gc: collectable <function 00C70E30>
>
>Since the main module is very big (more than 2800 lines of code) I do
>not understand which objects are not garbage collected.


They are being garbage collected. That's what the "collectable" part
of the message means. It's just a warning that those objects needed
to be garbage collected because they were refering to each other in
some sort of cycle. While the memory used was being wasted before the
garbage collector ran, it probably doesn't have any negative effect on
your program.

Ross Ridge

--
l/ // Ross Ridge -- The Great HTMU
[oo][oo] http://www.velocityreviews.com/forums/(E-Mail Removed)
-()-/()/ http://www.csclub.uwaterloo.ca/~rridge/
db //
 
Reply With Quote
 
Giampaolo Rodola'
Guest
Posts: n/a
 
      12-22-2007
On 22 Dic, 01:27, Ross Ridge <(E-Mail Removed)>
wrote:
> Giampaolo Rodola' <(E-Mail Removed)> wrote:
> >I'm in a big trouble since I don't know how to find some memory leaks

> ...
> >The message printed on screen is the following:

>
> >gc: collectable <function 00C70E70>
> >gc: collectable <type 00B41018>
> >gc: collectable <dict 00C6DE40>
> >gc: collectable <tuple 00C09900>
> >gc: collectable <tuple 00BCD510>
> >gc: collectable <function 00C70EB0>
> >gc: collectable <function 00C70E30>

>
> >Since the main module is very big (more than 2800 lines of code) I do
> >not understand which objects are not garbage collected.

>
> They are being garbage collected. *That's what the "collectable" part
> of the message means. *It's just a warning that those objects needed
> to be garbage collected because they were refering to each other in
> some sort of cycle. *While the memory used was being wasted before the
> garbage collector ran, it probably doesn't have any negative effect on
> your program.
>
> * * * * * * * * * * * * * * * * * * * * * * * * Ross Ridge


Uhm... that's a good news altough it doesn't seem to me that I used
any sort of cicle.
Thank you.
 
Reply With Quote
 
Istvan Albert
Guest
Posts: n/a
 
      12-22-2007
On Dec 21, 1:44 pm, "Giampaolo Rodola'" <(E-Mail Removed)> wrote:

> Since the main module is very big (more than 2800 lines of code)


maybe that is the actual problem to begin with,

you should refactor it so it it more modular and trackable, otherwise
this is just one of the many issues that will crop up,

just an opinion.

i.

 
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
Crystal Reports XI Dev Edition and IIS 6.0 - Memory Leak? Doug Odegaard ASP .Net 0 06-12-2007 05:38 PM
ASP net memory leak with crystal reports? =?Utf-8?B?QnJ5YW4=?= ASP .Net 0 10-16-2006 08:49 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



Advertisments