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

Such a simple example feeds my naive presumption that the system seems
broken. So could someone help me interpret this result ?

cheers -ben

Reply via email to