Ben

no stress. Now what I would love is an example that we can put in the uFFI chapter :)

Stef


Le 6/9/16 à 17:32, Ben Coman a écrit :
Apologies.   What a bogus post!   I must have been really tripping....

On Tue, Sep 6, 2016 at 9:26 PM, Ben Coman <b...@openinworld.com> wrote:
I thought I was starting to get a grip on how finalization work.  I
made this example...

     Object subclass: #MyObject
         instanceVariableNames: ''
         classVariableNames: ''
         package: 'Play'

     MyObject>>autoRelease
        ^ self class finalizationRegistry add: self

     MyObject>>finalize
         Transcript crShow: 'Finalizing MyObject'

     o := MyObject new autoRelease.
     o := nil.
     Smalltalk garbageCollect.   ==> 'Finalizing MyObject'

So far so good.  Extrapolating... I would *expect* this...

     oc := OrderedCollection new.
     10 timesRepeat: [ oc add: Libclang getClangVersion ].
     oc removeAll.
     oc := nil.
     Smalltalk garbageCollect.

...to print 'Finalizing MyObject' ten times, but it does nothing!!

Duh! I didn't send autorelease inside the timesRepeat above...

Duh^2 !!  that example didn't even refer to MyObject!!!!!

Of course fixing those two things to get...
     10 timesRepeat: [ oc add: MyObject new autoRelease. ].
works perfectly!

Such a simple example feeds my naive presumption that the system seems
broken. So could someone help me interpret this result ?
Sorry for the noise.  Pure PIBKAM**.  Couldn't see the trees for the forest.

cheers -ben


**problem is between keyboard and mouse.




Reply via email to