Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Cycle detection and object memory usage?

Reply
Thread Tools

Cycle detection and object memory usage?

 
 
Jim Kleckner
Guest
Posts: n/a
 
      05-21-2007
cycles:

I understand from the documentation that types with a finalizer method
that participate in cycles can't be collected.

What is the best way to go about finding these cycles?
Googling gives a variety of methods none of which seem terribly
mainstream for such a common problem.


Object memory usage:

Has anyone written a function to sweep out an object to discover how
much memory it and all the objects it references is using? This would
be great for performance tuning.

Thanks.

 
Reply With Quote
 
 
 
 
John Nagle
Guest
Posts: n/a
 
      05-21-2007
Jim Kleckner wrote:
> cycles:
>
> I understand from the documentation that types with a finalizer method
> that participate in cycles can't be collected.
>
> What is the best way to go about finding these cycles?
> Googling gives a variety of methods none of which seem terribly
> mainstream for such a common problem.


Put the Python garbage collector into debug mode and find out
what it reports as non-collectable.

Use weak pointers where appropriate to avoid cycles.
The general idea is that pointers back towards the root
of a tree structure should be weak pointers, which will
result in a cycle-free structure. I put that in BeautifulSoup,
and it works quite well.

John Nagle

 
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
c++ memory leak detection __jakal__ C++ 9 05-24-2012 08:39 PM
Memory Leak Detection Winbatch C++ 11 04-15-2009 01:57 PM
[graph java]cycle detection oliv@linuxmail.org Java 2 05-03-2007 09:16 AM
Object creation - Do we really need to create a parent for a derieved object - can't the base object just point to an already created base object jon wayne C++ 9 09-22-2005 02:06 AM
memory allocation logging for leak detection - problem with globals Spur C++ 1 05-09-2004 09:46 PM



Advertisments