Hello Nicolas,

When an abstract value is allocated using `alloc_abstract', a finalizer
can be attached to the memory area using `val_gc' which calls
`GC_register_finalizer'. If this abstract value keeps a pointer to
another neko value which points to the abstract (this happens when I
want to keep a reference to a neko `object' with a field pointing to the
abstract) then there is a cycle.
The gc can handle cycles properly, _except_ when a finalizer is
registered for an area in this cycle. In this case no finalizer will
ever be called and the memory will never be collected, because the gc
can't figure out in what order the finalizers should be called.

This is a major problem, because all memory involved in the cycle will
never be released.

There are two possible solutions:

 - expose the `GC_GENERAL_REGISTER_DISAPPEARING_LINK' function in neko
   in order to let the developper register a "disappearing link", which
   will allow the finalization pass to figure out a correct order.

 - use `GC_REGISTER_FINALIZER_NO_ORDER' to register the abstract
   finalizer, thus allowing the gc to call the finalizers in any order
   and release the memory properly.

The first solution is hard to get right and error prone.  OTOH the
second solution is possible only if neko's semantic doesn't guarantee a
finalization order or not.

Can you do something about it? :)

-- 
Clément Vasseur

--
Neko : One VM to run them all
(http://nekovm.org)

Reply via email to