Subj : Re: Memory growth problem To : netscape.public.mozilla.jseng From : "Mike McIntosh" Date : Mon May 19 2003 03:17 pm > Is there an example usage of this anywhere?. [I'll take a look at > JS_ResolveStandardClass and EnumerateStandardClasses.] Just noticed you already referred to js.c as an example usage. Thanks, Mike "Mike McIntosh" wrote in message news:baakbd$la63@ripley.netscape.com... > > I did want to get back to you on the scope object usage above. It seems > > fine, although there is a potential for unwanted sharing and security > > domain violation in the shared m_glob prototype. An option that avoids > > those hazards is to use JS_ResolveStandardClass from your > > global_class.resolve hook, and JS_EnumerateStandardClasses from > > .enumerate -- then you don't need the m_glob prototype with its standard > > classes, and each scope object gets only those standard objects that it > > actually uses > > Is there an example usage of this anywhere?. [I'll take a look at > JS_ResolveStandardClass and EnumerateStandardClasses.] > > I don't have a JS_SealObject API in my version. I have the 1.5-RC5 tarball > which I think is January 2003. > > Mike > > "Brendan Eich" wrote in message > news:3EC68D18.4030409@meer.net... > > > > >CSafeRequest request(m_cx); > > >JSObject* scope = JS_NewObject(m_cx, &global_class, m_glob, NULL); > > >if (scope) > > >{ > > > JS_SetGlobalObject(m_cx, scope); > > > jsb = JS_ExecuteScript(m_cx, scope, cjs->get_Handle(), rval); > > > JS_ClearScope(m_cx, scope); > > > } > > > > > >[The CSafeRequest just wraps up JS_SetContextThread/ > > >JS_BeginRequest/JS_EndRequest calls.] > > > > > >With the 'scoped' version I can see my finalizers being called for the > > >custom objects in the script. But there is still a steady build up of > memory > > >which seems to be being allocated via jsapi.c (line 1432):: JS_malloc. > > > > > Need the stack backtrace(s) for that JS_malloc, as I posted recently. > > > > I did want to get back to you on the scope object usage above. It seems > > fine, although there is a potential for unwanted sharing and security > > domain violation in the shared m_glob prototype. An option that avoids > > those hazards is to use JS_ResolveStandardClass from your > > global_class.resolve hook, and JS_EnumerateStandardClasses from > > .enumerate -- then you don't need the m_glob prototype with its standard > > classes, and each scope object gets only those standard objects that it > > actually uses. > > > > If you prefer to stick with the shared prototype, you'll want to use the > > JS_SealObject(cx, m_glob, JS_TRUE) on m_glob after you've called > > JS_InitStandardClasses on it, but before it is otherwise used. > > > > /be > > > > .