Subj : Re: SM: JS_ExecuteScript and rval To : Franky Braem From : Brendan Eich Date : Wed Apr 09 2003 02:56 pm > > >>If you keep the JSScript around after the constructor returns, you >>definitely have to root a script object that protects it (see >>JS_NewScriptObject in jsapi.h). >> >> > >I need to keep it, because the execute method needs the script object. But >instead of rooting, I add a property to wxScript which contains the Script >object. Does this solve the root problem? > > Of course -- a root is needed only by native code that wants a pointer or equivalent (jsval) to be a strong link that the GC starts marking the live-GC-thing graph from. A property is by definition a strong link in the live GC-thing graph, so long as the object containing the property is itself in the graph reachable from the root set. /be .