Subj : Re: GC Question To : MA From : Brendan Eich Date : Wed Jun 02 2004 09:33 pm > Thanks. Is there any reason why its not rooted? I know my life would be > much better, if it were already rooted. It's not rooted because callers do not always have access to a stack jsval to pass by reference (the interpreter's stack in each JSContext is scanned by the GC). So in too many cases, the caller of a getProperty or setProperty hook would have to do extra work, not required typically. Therefore it's up to you to manage by exception, via JS_AddRoot and JS_RemoveRoot calls. >>Did you really nest a GC within code that followed >> >> array = JS_NewArrayObject(cx, 0, NULL); >> *vp = OBJECT_TO_JSVAL(array); >> > > > Yes, I need to create many objects and store them as array elements. Do you need to create the array of objects in the getProperty hook, or could you do it earlier, say in resolve? Then you could define it as the value of the property identified by the id parameter to resolve, before populating it with objects, and all would be safe from GC. /be .