Subj : Re: JS_AddRoot & JS_RemoveRoot To : netscape.public.mozilla.jseng From : Brendan Eich Date : Fri Sep 05 2003 09:36 pm Edward Chan wrote: >Can you call JS_AddRoot multiple times for an object? > Yes, it just wastes cycles to do it more than once without an intervening JS_RemoveRoot. >And does every JS_AddRoot need to be matched with JS_RemoveRoot? > No. JS_RemoveRoot removes the addressed root, period, full stop. /be > For >example, if I do: > >JS_AddRoot(cx, &pObj); > >.... > >JS_AddRoot(cx, &pObj); > >.... > >JS_RemoveRoot(cx, &pObj); > >Is the JSObject pointed to by pObj still rooted and protected from being >gc'd (since I've called add twice, and remove only once)? Or does is it the >case that once JS_RemoveRoot is called, that's it, the obj is unrooted, and >gc'able? > >Thanks, >Ed > > > > .