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

Stephan Rudlof sr at evolgo.de
Wed Jun 21 22:31:53 UTC 2000


Lex,

thank you for the hint.

But I have two questions:

Lex Spoon wrote:
> 
> 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.

Which context where?

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

I cannot repeat the problem now, because it was quiet a time ago...
But it is possible that there were some contexts, because I often test
my code with 'self halt' expressions.

But these contexts should be diminish after closing the debugger
windows, isn't it?

BTW: Another place where objects could be hold with avoiding to be GC'ed
are workspace variables, which aren't defined as temp vars and
invisible.

Greetings,

Stephan


PS: There was a posting short time ago of a tool to ease finding root
objects (I think it is from Hans-Martin Moser); I will try this, if I
have such problems again.

> 
> -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

-- 
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