Garbage Collection in Python - current status of issue?

skaller skaller at maxtal.com.au
Tue Sep 28 16:16:35 EDT 1999


Neil Schemenauer wrote:
> 
> Ian Clarke <I.Clarke at strs.co.uk> wrote:
> >The FAQ (and related pages), however, while pointing out what the
> >various arguments and counter-arguments are, do not indicate whether
> >there is any ongoing work in this area - so is there any ongoing work in
> >this area?  What is the current status of this issue?
> 
> I have a patch for Linux (it probably works on other Unixes too):
> 
>     http://www.acs.ucalgary.ca/~nascheme/python/gc.html

[Uses Boehm conservative collector] 

There are several problems with this approach. The first is
related to executing __del__ methods. I also built a patch
for using Boehm, only my code deleted the reference counting
as well. Now, it is non-trivial to execute __del__ methods
synchronously without reference counting, or to execute
them properly, when both reference counting _and_ collector
finalisers are used.

The second problem is a portability nightmare. In fact, two of them.
The first nightmare is that your patch won't work with other versions
of Python, and is useless if you want to write code for distribution
that depends on GC, since that would require client patch their version
of Python.

The second nightmare relates to the way the collector interacts with
threads. In fact, the Boehm collector has to hack at implementation
details of the target operating system, since the POSIX thread API
does not provide thr required information.

Finally, there is an even worse problem with threading,
particularly on Linux. Boehm has to stop the world to do garbage
collection.
On Solaris, this is no problem, since Solaris threads are grouped within
a process. On linux,  there are no threads: all threads are processes,
and stopping the world has to stop the whole system.

Interestingly, Viper (my python interpreter/compiler)
has a different problem altogther. The current implementation
uses a full scale compacting, incremental, native (non-conservative)
garbage collector which is thread safe, but which doesn't support
finalisers. 
So my problem is not getting GC working, but calling __del__ methods.

-- 
John Skaller, mailto:skaller at maxtal.com.au
1/10 Toxteth Rd Glebe NSW 2037 Australia
homepage: http://www.maxtal.com.au/~skaller
downloads: http://www.triode.net.au/~skaller




More information about the Python-list mailing list