So is it ok to wrap alloc_root pointer as an abstract and store it
back in the original object?
The problem is that since your store your widget in your root, it
will never get GC'ed. You should consider alloc'ating a structure
that contains a list of connected events and store this list in your
widget abstract data. If the abstract data + the list is allocated
with alloc(), everything will be correctly GC'ed as soon as the
object is GC'ed. In general, trying to avoid as much as possible
alloc_root is a good idea.

Nicolas



I find the documentation for alloc_root confusing it seems to be saying
the opposite of what you said above

"Since the function is a value, it is needed to store it into a place
that can be accessed by the Neko garbage collector. This is why we
allocate a function_storage with the alloc_root Neko FFI function. The
alloc_root parameter is the number of values that can be stored in the
allocated pointer."

specifically ...

in your root, it  will never get GC'ed

and

store it into a place that can be accessed by the Neko garbage
collector. This is why we allocate a function_storage with the
alloc_root

Both are true :)

Storing a value in a root make it visible from the GC, so the memory it used is never reclaimed before the root is free'd.

Nicolas




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

Reply via email to