[Morphic][GC] How to remove/collect garbage in Morphic?

Lex Spoon lex at cc.gatech.edu
Wed Jun 21 08:00:43 UTC 2000


One odd place that will hold references is contexts.  If you put an
object into a temporary variable or argument, the object won't get GC'd
until the interpreter reuses that context and nils out all the temporary
variables.

Did you see any contexts showing up when you did your pointersTo:
searches?

-Lex



Stephan Rudlof <sr at evolgo.de> wrote:
> Dear Squeakers,
> 
> I have met the problem of generating objects which are not GC'ed as they
> should, while debugging drag&drop functionality for the morphic
> Browsers.
> It arises, if there is something interrupting a correct drag&drop
> operation (e.g. a Debugger) and Morphs to visualize the drag&drop
> operation remain. Removing these Morphs isn't a problem, but sometimes
> some Browser (models) seem to be referenced by some root object. I have
> searched for them quiet a long time (by SystemDictionary>>pointersTo:),
> but with no success.
> 
> I don't know where the problem is, but I have some observations:
> - EventHandlers in PluggableListMorphs reference browser models;
> - Browsers reference SystemWindows, PluggableListMorphs, etc.;
> - abandon/delete semantic for Morphs is not clear to me.
> 
> Some questions:
> 
> Is there an easy to use method to find root objects of a set of objects?
> 
> Isn't it true, that Squeak has no problems collecting garbage of objects
> with cyclic references?
> 
> What could these root guys are, which hold morphs not #deleted
> correctly?
> 
> What could these root guys are, which hold morphs #deleted correctly?
> 
> Isn't it true, that it is OK to just delete the parent Morph of some
> submorphs and let GC do the rest?
> 
> 
> Any ideas, hints, answers are very appreciated...
> 
> 
> BTW:
> 
> Code that seems to work for me - though I don't know exactly what in it
> (it has arised by many manually trials, and I just wanted to get rid of
> these annoying objects!), but it seems to be setting model to nil for
> Morphs referencing the Browser - is:
> ----
> 
> Utilities>>dragNDropDomestosStrong
> 	"for breaking bad dependencies"
> 	| winsWithoutOwner browserWins modelsWithDependents obsoleteModels
> morphs |
> 	self dragNDropDomestos.
> 	browserWins _ SystemWindow allInstances select: [:sw | sw model
> isKindOf: Browser].
> 	winsWithoutOwner _ browserWins select: [:bw | bw owner isNil].
> 	winsWithoutOwner do: [:win | win allMorphs do: 
> 			[:sm | 
> 			(sm respondsTo: #model)
> 				ifTrue: [sm model: nil].
> 			sm abandon]].
> "<comment>"
> 	"modelsWithoutDependents _ Browser allSubInstances select: [:bi |
> bi        
> 	    dependents isEmpty].            
> 	modelsWithoutDependents do: [:model | (Smalltalk pointersTo:
> model)        
> 	    do:             
> 	[:ref |             
> 	ref isMorph ifTrue: [ref abandon].            
> 	((ref respondsTo: #model)            
> 	and: [ref model == model])            
> 	ifTrue: [ref model: nil]]].           
> 	"
> "</comment>"
> 	modelsWithDependents _ Browser allSubInstances select: [:bi | bi
> dependents isEmpty not].
> 	obsoleteModels _ modelsWithDependents
> 				select: [:model | (model dependents
> 						detect: [:dep | (dep isKindOf: SystemWindow)
> 								and: [dep owner isNil]]
> 						ifNone: []) notNil or: [(model dependents detect: [:dep2 | dep2
> isKindOf: SystemWindow]
> 							ifNone: []) isNil]].
> 	obsoleteModels do: 
> 		[:model | 
> 		morphs _ model dependents
> 					select: [:dep | dep isMorph and: [dep pasteUpMorph isNil]].
> 		morphs do: 
> 			[:m | 
> 			m abandon.
> 			((m respondsTo: #model)
> 				and: [m model == model])
> 				ifTrue: [m model: nil]]].
> 	Smalltalk garbageCollect
> 
> ----
> 
> Greetings,
> 
> Stephan
> -- 
> Stephan Rudlof (sr at evolgo.de)
>    "Genius doesn't work on an assembly line basis.
>     You can't simply say, 'Today I will be brilliant.'"
>     -- Kirk, "The Ultimate Computer", stardate 4731.3





More information about the Squeak-dev mailing list