destructors, how?
Philip Metz
squeak-dev at lists.squeakfoundation.org
Wed Oct 23 12:09:04 UTC 2002
Pardon my ignorance, but how is it possible to access an object
*after* it has been GCd? My understanding is:
1. The object is GC'd, freeing its memory up for other use;
2. Some time later, finalization catches up to it and you
send the object a message.
Isn't it possible for the object's memory to be re-allocated to some
other purpose between 1 and 2 above? And therefore you
are unlikely to be able to the DB connection handle or whatever.
Is this understanding correct?
Philip Metz
At 05:23 PM 10/22/2002 -0700, Allen Wirfs-Brock wrote:
>At 04:08 PM 10/22/2002 -0700, Andrew Berg wrote:
>>It seems to me that it would be a workable comprimise
>>to use finalization for those objects which get/got
>>handed around and are hard to track, but then
>>something like an ensure: block to clean up the ones
>>where that is easy to do. It seems to me that it
>>would give you good performance in the common case,
>>but then CYA (without requiring reference counting) in
>>the complicated one. Does this just not work out well
>>in practice?
>
>It's probably more appropriate to use finalization as a debugging aid to
>catch "leaks" in your connection resource management scheme. Remember that
>garbage collectors generally make no guarantees about their latency in
>running finalizers. You may empirically discover that your scheme usually
>works but you still won't want to be caught by a "phase of the moon" change
>in GC latency. It's this unpredictability that generally makes
>finalization based resource recovery mechanism unreliable.
>
>Allen_Wirfs-Brock at Instantiations.com
>
>
>
>
More information about the Squeak-dev
mailing list
|