Re: re-initializing python, calling global destructors

Guido.van.Rossum@cwi.nl
Tue, 07 Mar 1995 10:22:00 +0100

> 1. Is there a way to re-initialize python from C so that it reclaims
> all the memory it has used?

Well, yes and no. You should be able to deduct which calls to make by
followinging what goaway() does -- basically,

cleanup();
doneimport();

However this won't reclaim memory that's referenced by circular links
(caused by e.g. "a = []; a.insert(a)" or doubly linked data
structures such as trees with parent and child pointers).

> 2. Is there a way to force python to call all global objects' destructors?

The phrase "global objects" could have many different meanings. There
is no global administration of all existing objects. Anyway, it's not
safe to call an object's destructor unless you know there are no
references left to it!

What exactly do you need this for?

--Guido van Rossum, CWI, Amsterdam <mailto:Guido.van.Rossum@cwi.nl>
<http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>