On Fri, 25 May 2007 18:20:42 +0200 Nicolas Cannasse <[EMAIL PROTECTED]> wrote:
> > Hi Nicolas > > > > In the code below I'm using alloc_root to save the object and > > function to call on a gtk callback. You'll notice the absense of > > free_root(), that's because gtk_signal_connect is a first time > > connection and can be called many times, so i don't want to free > > the neko callback data on the first event. > > > > So, the question is, I need to store the alloc_root pointer, and the > > best place to do so would be back in the object that's firing the > > event, then I can free the alloc_root data when the object is > > finalised. > > > > 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 ? http://blackdog-haxe.blogspot.com/ http://www.igameware.com "It is no measure of health to be well adjusted to a profoundly sick society." --Jiddu Krishnamurti -- Neko : One VM to run them all (http://nekovm.org)
