Closed
Bug 222635
Opened 21 years ago
Closed 21 years ago
Memory leak with with activated debugger support
Categories
(Rhino Graveyard :: Core, defect)
Rhino Graveyard
Core
Tracking
(Not tracked)
RESOLVED
FIXED
1.5R5
People
(Reporter: igor, Assigned: igor)
Details
Attachments
(3 files)
1.33 KB,
application/octet-stream
|
Details | |
478 bytes,
application/x-javascript
|
Details | |
1.01 KB,
patch
|
Details | Diff | Splinter Review |
When a debugger is attached to Rhino by Context.setDebugger, then a memory leak
occur as all local variable references are kept in memory. To test, save
Test.java and test.js from the following attachments and then compile Test.java
and run:
java Test test.js
Currently it prints ever increasing memory usage and then exit with OutOfMemory.
This is was originally reported by Dave Russo:
-------- Original Message --------
Subject: rhino memory leak(?) when debugger is attached
I think I've run into a memory leak in Rhino and I'd appreciate any
help/advice you can give.
I'm using Sun's JVM 1.4.1 on Solaris 5.8 and I'm getting an "out of
memory" exception when I run the following script inside our application
that embeds Rhino 1.5R4.1:
function fread(fileName)
{
var line =
"1234567890123456789012345678901234567890123456789012333333333";
var str = "";
for (var i = 0; i < 1000; i++) {
str += line + fileName;
}
return (str);
}
for (var i = 0; i < 2000; i++) fread("package.xml");
I've tried the latest Rhino tip and get the same results.
We've embedded rhino in a command line application which sets a custom
"debugger" (ShellDebugger) using:
cx.setDebugger(new ShellDebugger(), new ShellDebugContext());
and sets optimization level to -1 using:
cx.setOptimizationLevel(-1);
We're doing this because to get accurate line number information and
stack trace information when errors occur. ShellDebugger and
ShellDebugContext do nothing other than push and pop DebugFrame's from a
stack maintained in a ShellDebugContext. When an exception occurs we
can display the call stack with file and line number information.
It's possible that the leak is in our embedding and *not* in Rhino (if I
run the script above using "java -cp js.jar
org.mozilla.javascript.tools.Shell" there is not a problem.)
However, even if I remove *all* processing from ShellDebugger and
ShellDebugContext in our embedding, I get the memory exception from
Java. In addition, if I remove the following block (via the "false &&")
from org.mozilla.javascript.Interpreter, I don't get the exception:
if (false && debuggerFrame != null) {
if (argsDbl != null) {
args = getArgsArray(args, argsDbl, argShift, argCount);
argShift = 0;
argsDbl = null;
}
if (idata.itsFunctionType != 0 && !idata.itsNeedsActivation) {
useActivationVars = true;
scope = ScriptRuntime.initVarObj(cx, scope, fnOrScript,
thisObj, args);
}
debuggerFrame.onEnter(cx, scope, thisObj, args);
}
Is there any possibility that Interpreter has a memory leak when the
debugger is attached? Any help would be appreciated.
Thanks,
dave
Assignee | ||
Comment 1•21 years ago
|
||
Assignee | ||
Comment 2•21 years ago
|
||
Assignee | ||
Comment 3•21 years ago
|
||
The bug is regression since Rhino 1.5R3 and caused by my code to support
debugging of scripts that were loaded prior the debugger was attached. That
code forces creation of the activation object even for functions that otherwise
optimize it away so the debugger would see local variable. But I forgot to
update the part that releases the activation record and the patch addressed
that.
Assignee | ||
Comment 4•21 years ago
|
||
I committed the patch: Dave Russo confirmed that his problem went away.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•