In order to better test this we created the following test function:
var MAX_INDEX = 200000;
function runTest() {
var strs = [];
for(var i = 0; i < MAX_INDEX; ++i) {
strs.push('A relatively long string containing ' + i + ' as a
randomizer');
}
for(var j = 0; j < MAX_INDEX; ++j) {
delete strs[j];
}
delete strs;
}
In the above test, mozilla eats up 60MB of RAM and does not release it
even upon reload or changing pages. As I mentioned above it only
releases only when you shut down mozilla. We tested the same script on
IE 6 and it does not suffer from the same problem (it releases the
memory as soon as the function is complete).
We have been able to replicate this problem on Mozilla 1.4, 1.6 and
Firefox 0.8. Any input would be greatly appreciated.
> I'm not sure if this is the proper forum for this type of question. The
> company I work for has developed a 100% Javascript application
> development framework (approx. 29k lines of code). We are running into
> memory leak issues with mozilla when running our application. It appears
> that mozilla is not freeing memory after the application has run. The
> only way to free the memory is to shutdown mozilla (closing all mozilla
> windows).
>
> In order to better test this we created the following test function:
>
> var MAX_INDEX = 200000;
>
> function runTest() {
> var strs = [];
>
> for(var i = 0; i < MAX_INDEX; ++i) {
> strs.push('A relatively long string containing ' + i + ' as
> a randomizer');
> }
>
> for(var j = 0; j < MAX_INDEX; ++j) {
> delete strs[j];
> }
>
> delete strs;
This has no effect, because per ECMA-262, variables declared with var
have attribute DontDelete (JSPROP_PERMANENT in SpiderMonkey API terms).
> }
>
> In the above test, mozilla eats up 60MB of RAM and does not release it
> even upon reload or changing pages.
The GC is certainly being run when the page unloads. Perhaps you are
calling a leak something else: the malloc heap holding onto memory
allocated to the process.
If you're comparing on Windows, maybe the only problem (a surface
effect, really, given how virtual memory works, unless you're on the
edge of running out of, or the OS is on the edge of overcommitting,
virtual memory) may be that Mozilla does not call _heapmin or whatever
it's called.
Let's talk about this in the DOM group for now.
/be