gc issues

Martin von Loewis loewis at informatik.hu-berlin.de
Fri Jun 8 13:27:06 EDT 2001


etoffi at bigfoot.com (e toffi) writes:

> i know this will require some *very* careful prgramming techniques.
> can anyone point me in the right direction?

Basically, you need to announce the objects of one language to the
other language's garbage collector. E.g. when you provide Smalltalk
objects to a Python interpreter, you probably do this by creating
Python wrapper objects. So you need to tell the Smalltalk garbage
collector that the object is alive as long as there is a Python
wrapper around it. How you do this would depend on the Smalltalk GC
API.

A Python object is normally released by having its reference counter
drop to zero. If that happens, the Python wrapper is released, and
should tell the Smalltalk GC that now the ST object is now available
for collection again.

If you can create cycles involving both ST and Py objects, things
become complicated. For Python, you need to implement a traversal
function that enumerates all directly-reachable Python objects from an
ST object. That probably means that you need traversal capabilities on
ST objects. Whether this is possible and how this is done again
depends on the details of the ST GC API.

To summarize: as long as you don't create cycles involving objects
from both languages, you only need to make sure that objects
referenced from one language are not collected by the collector of the
other language. If you have cycles of mixed languages, I doubt there
is prior art integrating the GC routines.

Regards,
Martin



More information about the Python-list mailing list