help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] OOP leaking with registered object


From: Holger Hans Peter Freyther
Subject: Re: [Help-smalltalk] OOP leaking with registered object
Date: Tue, 7 Apr 2015 19:22:24 +0200
User-agent: Mutt/1.5.23 (2014-03-12)

On Tue, Apr 07, 2015 at 06:18:13PM +0200, Roland Plüss wrote:

> I'm using a similar trick in my own scripting language. Hoped I can get
> away in Smalltalk without it. It's certainly a working solution albeit
> not the most good one. Should do the trick for the time being.

Okay, what else do you think the VM can do? E.g. if I would
implement a "shutdown" command I would suspend all processes,
then run the global collection, then look at gcArray iterate
over them to call mourn.

"Stop the normal handling"
proc := (Process allInstances select: [:each |
                each name = 'finalization listener']) first suspend

"Check if other finalizers run or wait..This runs the risk if
new garbage is produced.. the vm will be upset and aborts.."
[(Process allInstances select: [:each | each name = 'finalization worker']) 
isEmpty]
        whileFalse: [Processor yield]


"Run GC which will signal finalization.."
ObjectMemory globalGarbageCollect

"Take the to be finalized array and mourn"
garbage := Processor instVarNamed: #gcArray
garbage ifNotNil: [garbage do: [:each | each mourn]]


Specially step 1 and 2 is a bit dangerous. You should suspend
other processes/work too to prevent from more GC to be produced.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]