Garbage collection questions

Tim Peters tim.one at home.com
Thu Jun 14 01:39:22 EDT 2001


[Sophie Coon]
> I have problems to understand how the garbage collector works.
> If I understood well the documentation a collectable objects is an
> unreachable objects that will be garbage collected. So if I do a
> gc.collect() and it returns 280 but the gc.garbage list is empty that
> means that the memory taken by these 280 objects has been freed ?

Yes.  However, there's rarely a good reason to call gc.collect() manually --
collection happens automatically.  Note that gc will not collect trash
cycles containing objects with destructors (the intended order of
destruction is impossible to guess then), and *those* are the (only) things
that end up in gc.garbage (if any such exist).





More information about the Python-list mailing list