Hi, I've been playing with the very simple script shown below. I've set up
an embedded debugger application so I can watch the script execution line by
line.
What I have been trying to answer is exactly how garbage collection works in
Rhino.
In this example I have defined a variable "x" on line 1, then, on line 2 I
decide I no longer need the variable, so I set it to null.
At each line of the script, the debugger pauses and I am performing the
following steps:
1) run System.gc()
2) this.wait(5000)
3) printing out a list of all variables stored in the top-level
scope
At some point I was hoping that x would be de-allocated (removed from the
scope), however it never happens, it always remains visible in the top level
scope.
What is necessary for a variable to be garbage collected? I will be
executing a large number of concurrent scripts, and memory is of concern to
me.
Thanks!
David
______________________________________________________
var x=1;
x=null;
var y=2;
z=3;
function goHere(a){
var b=5;
c=6;
return (a+b+c);
}
var d = goHere(10);
y = null;
var f = c;
var g=true;
______________________________________________________
Results (with only outputting the value of "x"):
At Line #: 1 : [var x = 1;]
x: [EMAIL PROTECTED]
At Line #: 2 : [x = null;]
x: 1.0
At Line #: 3 : [var y = 2;]
x: null
At Line #: 4 : [z = 3;]
x: null
At Line #: 10 : [var d = goHere(10);]
x: null
At Line #: 5 : [function goHere(a) {]
At Line #: 6 : [ var b = 5;]
At Line #: 7 : [ c = 6;]
At Line #: 8 : [ return (a + b + c);]
At Line #: 11 : [ y = null;]
x: null
At Line #: 12 : [var f = c;]
x: null
At Line #: 13 : [var g = true;]
x: null
Process finished with exit code 0
______________________________________________________
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino