468,293 Members | 1,867 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,293 developers. It's quick & easy.

Cycle detection and object memory usage?

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.

May 21 '07 #1
1 1241
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

May 21 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

60 posts views Thread by Fotios | last post: by
9 posts views Thread by Jimmy Cerra | last post: by
7 posts views Thread by mosaic | last post: by
8 posts views Thread by Gawain Lavers | last post: by
8 posts views Thread by kk_oop | last post: by
1 post views Thread by Jean-Paul Calderone | last post: by
10 posts views Thread by Conrad Lender | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.