[squeak-dev] Best practice(s) to delete an object?

John M McIntosh johnmci at smalltalkconsulting.com
Wed Feb 27 03:51:13 UTC 2008


On Feb 26, 2008, at 3:48 PM, itsme213 wrote:

> I have this object, X, I want to delete (typically from within the  
> context
> of some other object Y). So I remove it from Y (set some Y instVar  
> to nil,
> or remove it from some collection instVar of Y). I mark X 'deleted'.


Well first I'll note if you use weak logic the deal is the object that  
is only weak referenced will
be deleted sometime in the future, where the future is milliseconds or  
maybe days, well maybe not
days, but if you expect milliseconds, then 5 seconds can kill you.   
This is related usually to how
the GC does with cleaning up weak reference and how it interacts with  
the smalltalk code which
usually runs to do the finalization which in Squeak isn't robust  
enough to deal with 10,000's of objects.

Now to be clever you could use

PointerFinder pointersTo: anObject except: objectsToExclude

or

variations of become:


We have discussions back and forth (no resolution yet) about finding  
things in Sophie given *limited* memory for book object, well like
a weak value dictionary that when an object needs data looks into by  
holding on to the uuid. If found or needs to load, we load into the  
weak dictionary
later when all the owners get GCed, then the object will at some point  
disappear. Well that or storing the data in cache limited to N MB and  
always doing
a lookup when you need to use the data, so the owner only holds the  
key not the data.


I note in Sophie we can make the entire Sophie system *disappear*  
because we gone to great
pains to ensure removal of certal SophieClass instances and references  
in the right places make the entire Sophie
system GC-able.

--
= 
= 
= 
========================================================================
John M. McIntosh <johnmci at smalltalkconsulting.com>
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
= 
= 
= 
========================================================================





More information about the Squeak-dev mailing list