Subj : Re: Garbage Collection Woes To : netscape.public.mozilla.jseng From : "Stephen Jones" Date : Fri May 02 2003 09:00 am Hi Brendan, thanks for the feedback. Iterating over all contexts, I am definately seeing different objects GC'ed for each context I pass in. Should I assume: 1. Objects are being incorrectly GC'ed when I pass in different contexts, or 2. Objects that are being GC'ed when passing through one context, release other objects that are GC'ed when the next context is iterated. I'm definately passing the address of JSObjects to be rooted. I have one base C++ class that handles this. I've temporarily solved this problem by ref-counting my objects and calling RemoveRoot when the ref-count is zero, but I'd like to figure out a real solution. Thanks, - S "Brendan Eich" wrote in message news:3EB1C5E9.60802@meer.net... > Stephen Jones wrote: > > >One more piece of information . . . this only seems to happen to objects > >created in contexts other than the global context . . . am I doing > >something wrong when executing GC? This is the code I am using . . . > > > > while( ( theCurrentContext = JS_ContextIterator( m_JSRunTimePtr, > >&theContextIterator ) ) != NULL ) > > { > > JS_GC( theCurrentContext ); > > } > > > >Is the "live-thing" graph different for different contexts? > > > > > > No. > > Therefore you don't need to call the GC more than once per runtime, > using any context created in that runtime. > > You shouldn't add a bunch of JS_AddNamedRoot calls without knowing why > you need each one. Remove all that you don't believe you need. > > Make sure you aren't passing object pointers or jsvals by value to > JS_Add*Root. You have to pass the address of a JSObject* or jsval to > register a root. > > /be > .