By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,034 Members | 2,000 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,034 IT Pros & Developers. It's quick & easy.

Cycle detection and object memory usage?

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.