fixed address objects (was Calling straight C code)

Ken Dickey KenD at apple.com
Tue Mar 9 23:54:38 UTC 1999


agree at carltonfields.com wrote:
> 
> ...  In cases where there ARE cross-references (the reason why you care that the memory must be fixed address objects), it may not be appropriate to murder the object simply because the Squeak world lost its references to it.  Squeak WILL NOT KNOW whether another fixed memory block is pointing to the byte-array.  Accordingly, finalization may be very application-specific, and it may not be desirable to finalize the fixed memory just because Squeak dropped its reference.
> 
> Consider the POSIX regular expression interface.  ...  Squeak has no need or interest to hold handles to the variable sized objects, although they may well be allocated via ExternalByteArray. 

Typically this is handled by specializing the finalizer.  In the POSIX RegExp case, the specialized finalizer cleans up the 'internally referenced' objects (perhaps as a Squeak call to C code which 'does the dirt').  The 'foreign' finalizer might, for example, decrement a reference count rather than release 'externally allocated' storage in order to maintain some invariant.

If Squeak gc does not find references to some object, it certainly should finalize it!  The problems in most cases are [1] making sure that the finalization occurs 'soon enough' w.r.t. some global context, and [2] making sure that order invariants are maintained (i.e. deallocating 'interior objects before containers, et cetera).  [This is pretty well covered in the literature on finalization].

Cheers,
-KenD





More information about the Squeak-dev mailing list