Subj : Re: GC question To : netscape.public.mozilla.jseng From : lyg Date : Fri May 28 2004 02:46 pm "Sterling Bates" wrote in message news:c968kv$qhc1@ripley.netscape.com... > lyg wrote: > > because when i open a new document, i need a "root object" to manager the > > objects created in the new document, I have to create many global objects > > for the root objects. when I access the opened document, i just fetch the > > rooted "root object" and JS_SetGlobalObject(). In other words, at the same > > time, there is only one object as the global object and the others are > > rooted not to GCed. When i want close the document, I will > > JS_RemoveRoot(rootedObj) to let it GCed. Now it > > is not the global object, why not be GCed? > > 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. It seemed that the problem is solved with adding a sentence. JS_RemoveRoot(cx, &rootedObj); JS_ClearScope(cx, rootedObj); would someone tell me why I must JS_ClearScope(cx, rootedObj)? thanks again. .