Subj : Re: JS_GetArrayLength() crashing (garbage collection issue) To : sebastien maraux From : Brendan Eich Date : Fri Feb 25 2005 10:50 am > A children is typically added with > JSObject *localObj = JSConstructObject(...my objectClass...); > JS_AddRoot(context, &localObj); > jsval localVal = OBJECT_TO_JSVAL(localObj); > JS_SetElement(Context, pDataHolder, (jsint) u4Index, &localVal ); > > But (I guess that) as it is local, localObj is being deleted, causing > a bit later a JS_GC call to crash. Don't guess, and don't root unnecessarily. If pDataHolder is rooted or well-connected, you shouldn't need to root localObj above. Have you read http://www.mozilla.org/js/spidermonkey/gctips.html yet? How is pDataHolder protected from GC? /be .