Subj : Re: question: memory allocated by JS_Enumerate(). To : netscape.public.mozilla.jseng From : jp Date : Fri May 06 2005 08:34 pm Brendan Eich wrote: > jp wrote: > >> >>>> 2. It seems, if I don't use JS_DestroyIdArray() to release the >>>> pointer, the memory will not be released even after I destroy the >>>> context and runtime. Is that true? >>> >>> >>> >>> >>> >>> Yes. >>> >>> >> >> just curious, why did you decide that this pointer not being managed >> by runtime? > > > > The JS GC is not "conservative", it cannot magically tell when you are > done using an arbitrary piece of memory. It handles only certain > well-aligned allocations, and it marks them starting from a set of > "roots", which you must supplement when your embedding holds pointers to > GC-things in C or C++ data structures in the malloc heap and in static > memory. > > The manually allocated data structures are used in a LIFO fashion, most > of the time, so it is not a great hardship to require that they be freed > or destroyed by hand. > > /be could you tell me where I can find more detailed info (any reading or a particular piece of code) on the GC mechanism used by SM. Since our code will heavily use SM, i want to know it better. .