Tracking down a memory leak

Martin von Loewis loewis at informatik.hu-berlin.de
Sun Jan 20 10:52:27 EST 2002


Bruce Dawson <comments at cygnus-software.com> writes:

> My understanding is that garbage collection in Python was introduced solely
> to deal with circular references. In other words, the presence of circular
> references is the only reason for garbage collection.

People often refer to the automatic memory management that Python does
by means of reference counting also as "garbage collection". I think
this is how the OP used the term; in books predating 2.0, you will
read statements that presence of cycles defeat this kind of garbage
collection.

To be absolutely clear in terminology, I usually refer to the older
mechanism as "reference counting" and to the more recent one as
"collection of cyclic garbage".

> You could try explicitly invoking the garbage collector. If your
> problem is circular references that should free them.

If the OP uses Python 2.x (which is not clear from the post), the
collector should get invoked often enough to make explicit invocation
unnecessary.

Regards,
Martin



More information about the Python-list mailing list