Leakage vs Cyclops

Martin v. Löwis martin at v.loewis.de
Fri Jan 3 15:37:55 EST 2003


Robin Becker <robin at jessikat.fsnet.co.uk> writes:

> With upper limit of 900 pages the peak working set is 15M with 2700
> it rises to 45M. This seems to be a real leak, but how can I track
> it down?

I'd use some of the more recent checking facilities: 

1. set the gc debug flags to gc.DEBUG_STATS, then invoke gc.collect(),
   then check how many new objects where collected.

2. check gc.garbage to make sure you don't have cycles with
   finalizers.

3. invoke gc.get_objects from time to time, and print its length, to
   see the total number of container objects. Verify that it is indeed
   growing over time.

4. count the list of container objects by type, print the number of
   objects per type, to find what new objects you are allocating. If
   these are instance objects, further divide them by class.

5. Once you have an object which keeps a lot of other objects alive,
   and which should have been released, use gc.get_referrers to find
   out why it is still alive itself.

HTH,
Martin





More information about the Python-list mailing list