[Vm-dev] [ENH] A better finalization support (VM & language side)

Igor Stasenko siguctua at gmail.com
Mon Mar 8 21:31:24 UTC 2010

Please, review the

There are two sets of changesets - one for vmmaker and other is for

A VMMaker changeset is based on VMMaker-dtl.159.

Here the little benchmark, between old and new weak registries:

{ WeakRegistry. WeakFinalizationRegistry } collect: [:class |
   | registry weaklings time1 time2 |
   registry := class new.
   WeakArray removeWeakDependent: registry.

   weaklings := (1 to: 100000) collect: [:i | Object new ].
   time1 := [ weaklings do: [:each | registry add: each ] ] timeToRun.
   weaklings at: 100 put: nil.
   Smalltalk garbageCollect; garbageCollect.
   time2 := [ registry finalizeValues ] timeToRun.
   time1 @ time2
 {7816 at 41 . 4114 at 0}

While its not much better at first benchmark (since using the same
approach to store objects in one dictionary),
while other is significant, since there is no longer need to scan a
whole collection to detect an items which become a garbage.

Btw, i wonder, why current WeakRegistry using a WeakKeyDictionary
instead of WeakIdentityKeyDictionary?
Isn't a weak refs is identity-based?

I am also a bit wonder, why WeakRegistry has to support a copy protocol?
It may lead to unpredictable behavior once you try to copy such kind
of container, no matter how well you protect it.

Best regards,
Igor Stasenko AKA sig.

More information about the Vm-dev mailing list