Hi Atul, Check out this thread from 2006 ...

---------- Forwarded message ----------
From: Stewart Cambridge <stewart.cambridge@gmail.com>
Date: 2006/9/26
Subject: Re: [Beanshell-users] Massive memory usage in BeanShell not GC'ing
To: David Lee <dlee@calldei.com>


It is the recursive self-references which cause the hang up.
The solution I use is that whatever is holding a reference to the
interpreter has to manually clean up, before it is destroyed itself.

Basically this is a wrapper class around the interpreter object.

protected void finalize()
 if( this.interpreter != null )
   this.interpreter = null;


On second thoughts, maybe the this should be code in the Interpreter
class itself, and patched onto Beanshell itself?

protected void finalize()


On 26/09/06, David Lee <dlee@calldei.com> wrote:

I'm running into what looks like a similar case to Stewart 's  post 2 months
ago about BeanShell and GC.
Unlike Stewart I have not yet been able to isolate it to a simple case ...
but its very clear.
I'm calling massive numbers of  either eval() or BshMethod.invoke() ... and
the memory usage is going through the roof until I run out of VM and crash.
 I've tried every trick I can think of to no avail.
Unreferencing the Interpreter instances does not allow the GC to reclaim
memory !!!
I've moved references which may cycle back to "this" into thread local
storage, and string indexed maps outside the interpreter in hopes that the
problem would go away ... no go.

If I cant find a solution to this I may have to rip out BeanShell and
replace it with something else ... what ? I don't know ... maybe pure java
with javac ... yuck yuck yuck ...

I didn't notice this problem earlier and now of course its getting close to
deadline :(
Earlier I tested with hundreds of calls and the memory use was reasonable,
but when I scale up to say 100,000 eval() or BshMethod.Invoke calls, which
in turn call into my code ... it eats up 200mb+ very quickly and the only
recourse is killing the java process and starting over ...

Any suggestions at all on where I could look to possibly work around this
issue are greatly appreciated.


David A. Lee
VP Engineering
Nexstra, Inc.
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash

Beanshell-users mailing list