[Vm-dev] off-topic garbage

Ben Coman btc at openInWorld.com
Sun Dec 14 13:54:17 UTC 2014


Bert Freudenberg wrote:
>  
> 
> 
> ------------------------------------------------------------------------
> 
> 
>> On 14.12.2014, at 05:32, Ben Coman <btc at openInWorld.com> wrote:
>>
>> David T. Lewis wrote:
>>> On Sat, Dec 13, 2014 at 12:00:43PM -0800, Eliot Miranda wrote:
>>>> Hi All,
>>>>
>>>>    I'm debugging the 64-bit variant of the Spur GC, having got the real
>>>> 64-bit Spur Stack VM to start-up and progress to the first GC (albeit with
>>>> the border of a window displayed in the wrong colour).
>>> Congratulations!
>>>> In doing so I
>>>> looked at the list of to-be-collected objects at the first full GC in the
>>>> simulator.  I'll list them here.  What are they you wonder?  These are the
>>>> objects that are unreachable in a snapshotted image that has been converted
>>>> to 64-bits.  So they're objects that I suspect are always reclaimed on the
>>>> first GC.  They're the objects comprising the screen menu that was opened
>>>> to save and quit the image.  Here's ones I printed out to investigate:
>>>>
>>> Interesting catch. It makes sense when you think about it, but I never would
>>> have thought about it.
>>> Dave
>> So we should be doing a garbage collect in #snapshot:andQuit:
>> right before the call to #snapshotPrimitive ?
> 
> Wouldn't help. The snapshotPrimitive does a full GC.

Nice to know.

> This is stuff that is held onto by the method context invoking snapshotPrimitive, or recreated by the startup code. If you do a GC immediately after loading an image, before running any startup code, nothing is freed. I just tried.
> 
> It will be freed only after the menu handler returns. Here's the stack as saved in the image. You can easily see this in SqueakJS by running the image with the "step" button (so it will immediately break into the debugger before executing the first bytecode):
> 

Ahh. So then what about letting the menu handler return before 
snapshotting.

> [] in BlockClosure>>newProcess
> [] in MorphicProject>>spawnNewProcess
> PasteUpMorph>>doOneCycle

e.g. Call #snapshot:andQuit:withExitCode:embedded: from here after stack 
has unwound, something conceptually like this...


     PasteUpMorph>>doOneCycle
       [ WorldState doOneCycleFor: self ]
            on: SnapshotAndQuit do: [ :ssaq | ssaq execute ].


> WorldState>>doOneCycleFor:
> WorldState>>doOneCycleNowFor:
> WorldState>>handsDo:
> SequenceableCollection>>do:
> [] in WorldState>>doOneCycleNowFor:
> HandMorph>>processEvents
> HandMorph>>handleEvent:
> HandMorph>>sendMouseEvent:
> HandMorph>>sendEvent:focus:clear:
> HandMorph>>sendFocusEvent:to:clear:
> PasteUpMorph>>becomeActiveDuring:
> BlockClosure>>on:do:
> [] in HandMorph>>sendFocusEvent:to:clear:
> MenuMorph>>handleFocusEvent:
> Morph>>processEvent:
> Morph>>processEvent:using:
> MorphicEventDispatcher>>dispatchEvent:with:
> MorphicEventDispatcher>>dispatchDefault:with:
> Morph>>processEvent:using:
> MorphicEventDispatcher>>dispatchEvent:with:
> MorphicEventDispatcher>>dispatchDefault:with:
> Morph>>handleEvent:
> MouseButtonEvent>>sentTo:
> MenuItemMorph>>handleMouseUp:
> MenuItemMorph>>mouseUp:
> MenuItemMorph>>invokeWithEvent:
> Cursor>>showWhile:
> BlockClosure>>ensure:
> [] in MenuItemMorph>>invokeWithEvent:
> TheWorldMainDockingBar>>saveAndQuitSqueak


     TheWorldMainDockingBar>>saveAndQuitSqueak
       (SnapshotAndQuit new with: self snapshot: true andQuit: true)
            signal.


     Notification subclass: #SnapshotAndQuit
         instanceVariables: 'smalltalkImage save quit'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Something'


     SnapshotAndQuit>>with: paramSmalltalkImage
                      snapshot: paramSave
                      andQuit: paramQuit
         smalltalkImage := paramSmalltalkImage.
	save := paramSave.
         quit := paramQuit.


     SnapshotAndQuit>>execute
         smalltalkImage snapshot: save andQuit: quit embedded: false


> SmalltalkImage>>snapshot:andQuit:
> SmalltalkImage>>snapshot:andQuit:embedded:
> SmalltalkImage>>snapshot:andQuit:withExitCode:embedded:

cheers -ben







More information about the Vm-dev mailing list