GC In Python: YAS (Yet Another Summary)
markusk at bidra241.bbn.hp.com
Mon Jun 28 09:58:28 CEST 1999
Andrew Dalke <dalke at bioreason.com> writes:
> Stuart Yeates <syeates at cs.waikato.ac.nz> said to me:
> > I'm not quite sure what you mean by 'integer handle,' but if you
> > do a straight cast then it shouldn't be a problem (since the
> > collector operates on the binaries representation). If you mean
> > that it uses an index to an array of pointers (or some such),
> > then that shouldn't be a problem either, since the pointer still
> > exists somewhere (i.e. the array).
> The latter. Example object creation code might look like:
> dt_Handle mol = dt_smilin("CCC", 3);
> where dt_Handle is a typedef to unsigned long. In the SWIGged
> wrapped version, this is mol = dt_smilin("CCC").
> Yes, the library has a pointer table to the object. The problem
> I see is, how does the Boehm collector (or other GC) know what to
> collect from this vendor library? I can't see how, given that
> my Python code stores it as an integer.
As long as you have a pointer to the array it will not be reclaimed by the GC.
The integer doesn't count as a pointer. It wouldn't count in any GC I know.
The Boehm Weiser collector also has special support for interior
pointers, which are pointers into an array.
> That's why I don't see how you say "It fully supports C and C++"
> when this is a package which doesn't do "pointer XORing or other
> crimes" but cannot be usable with a GC w/o modifications.
The claim is right. Even in a cooperative environment your integer
wouldn't count as a reference to an object.
> But then, I'm a computational biophysicist by training and don't
> know much about GC other than the general concepts. One of the
> references on the SGI page says Boehm can be used in "uncooperative
> environments" so I'll end by saying that I don't know enough.
The Boehm collector is a conservative collector, which means it just
scans the memory and if there's an integer that points to a valid
address it wouldn't reclaim the object at this address.
Your integer wouldn't probably be a valid address and therefore
wouldn't be counted by the GC.
Markus Kohler mailto:markus_kohler at hp.com
More information about the Python-list