Subj : Garbage collection To : netscape.public.mozilla.jseng From : Jochen Stier Date : Fri Sep 03 2004 11:11 am Hi, I am doing the following.... sJSRuntime = JS_NewRuntime(0x100000); sJSContext = JS_NewContext(sJSRuntime, 0x1000); sJSProto = JS_NewObject(sJSContext, &sJSClass, NULL, NULL); JS_AddRoot(sJSContext, &sJSProto); for (int j=0; j<10; j++) { JS_NewObject(sJSContext, &testClass, 0, sJSProto); } JS_GC(); What happens is that 10 object are being gc-ed, allthough they are a "child" of sJSProto. Am I missing something here ? How can I protect the 10 objects from being gc-ed themselves. I cannot use JS_AddRoot within the loop because &lObject is always the same .... for (int j=0; j<10; j++) { JSObject* lObject = JS_NewObject(sJSContext, &testClass, 0, sJSProto); JS_AddRoot(sJSContext, &lObject ); } Basically I am trying to build a cache of objects during startup and new delete them till shutdown. Cheers Jochen .