GC In Python: YAS (Yet Another Summary)

Reimer Behrends behrends at cse.msu.edu
Sat Jun 26 07:57:38 CEST 1999


Andrew Dalke (dalke at bioreason.com) wrote:
[...]
> 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.

The Boehm collector is conservative; it will treat any word in
memory as a potential pointer until proven otherwise. It uses a
number of sophisticated methods to avoid misidentifying integers
as pointers. Surprisingly enough, this approach works pretty well
in practice. I've used it more than once to reign in a misbehaving
C program (which leaked memory or freed storage prematurely).

> 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 few practices that are unsafe should be avoided by programmers,
anyway. Like xoring pointers together, or doing similar ugly things.
Most programs are pretty well-behaved.

[...]

				Reimer Behrends




More information about the Python-list mailing list