In our application we are using spidermonkey compiled with threadsafe
option. We have one single runtime which is shared among all requests
while for each request we are creating a new context and destroying it
using JS_DestroyContextNoGC. The GC is running as a background thread
which activates after every 5 secs.
Now one thing that I observed is that if my script creates lot of new
objects then the memory of the process increases and this memory does
not come down even after GC is run. The problem is in case of
multiuser scenario, in which case there is considerable increase in
memory of the process. For eg. this is the sample script that I used
var FullDimensionality = new Array( "Growth Platform","Resource
var tmpTupSet = new A_TupleSet(FullDimensionality,FullDimensionality);
var tmpTuple = new A_Tuple(tmpTupSet);
//create an Array of Tuples with 1000 tuples in it
var tupArray = ;
for(var i = 0; i < 1000; i++)
tupArray[i] = tmpTuple.getDifferent(tmpTuple);
print("Created tuple array with 1000 tuples");
var childCursorArr = new Array(1000);
for(var j =0; j < 1000; j++)
//create 1000 cursors
childCursorArr[j] = new A_Cursor(tupArray,tupArray,new
print("Created 1000 cursors with 100 tuples each");
As can be seen that Iam creating about 2000 objects or so in the
script, of which the object of type A_Cursor consumes lot of memory.
Now when I run this script for 1 user the process memory increase to
330 Mb from 200 Mb and when I run this for 2 users simulanoesly then
process memory increses to 550 Mb. For 100 users the memory increased
upto 8Gb. Although it did come down to 3Gb later. I have ensured that
there is no memory leak using valgrind for the purpose and also
verified that objects are getting deleted properly when GC is run.
So it seems that GC heap acquires the memory and resues it without
releasing it once the objects are deleted. Am I right in understanding
so? If so, then when it is that this memory is actually freed up??
Beacuse right now It seems that this memory is released pretty
randomly which can be quite affecting in our application where 100s of
users can connect randomly. Also is it possible to set a limit as to
how much maximum memory can be reused ??