Subj : Re: GC question To : netscape.public.mozilla.jseng From : Sterling Bates Date : Fri May 28 2004 08:02 am lyg wrote: >>Try deleting the object from whatever scope you've created it under. >> > > Thanks for your answer,but i am sorry, I do not understand the upper > sentence. I was referring to JS_DeleteProperty, but it seems JS_ClearScope fixes your issue :) > JS_RemoveRoot(cx, &rootedObj); > JS_ClearScope(cx, rootedObj); > > would someone tell me why I must JS_ClearScope(cx, rootedObj)? > thanks again. If I understand GCing correctly, it does not attempt to free objects that are tied to a scope (ie another object). If you are creating your rootedObjs as properties of the global object, they will not be GCed until they are no longer properties of that object. See the last GC example at http://www.mozilla.org/js/spidermonkey/gctips.html. The array object needs to be rooted immediately, but the JSStrings created later do not require rooting since they are (very quickly) scoped to the array. I'm sure Brendan will correct me if I'm way off. Sterling .