Fwd: Massive memory usage in BeanShell not GC'ing

"Stewart Cambridge" <[email protected]> Tue, 21 Oct 2008 14:53:01 +0100
Newsgroups gmane.comp.java.beanshell.user
Message-ID <[email protected]>
Hi Atul, Check out this thread from 2006 ...

---------- Forwarded message ----------
From: Stewart Cambridge <[email protected]>
Date: 2006/9/26
Subject: Re: [Beanshell-users] Massive memory usage in BeanShell not GC'ing
To: David Lee <[email protected]>


http://groups.google.co.uk/group/comp.lang.java.programmer/browse_thread/thread/5142bb824b09e544/ea06d4d7205a24a8

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.getNameSpace().clear();
   this.interpreter = null;
 }
}

HTH

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

protected void finalize()
{
   this.getNameSpace().clear();

}



On 26/09/06, David Lee <[email protected]> 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.
>
> Thanks
>
> ------------------------------------------------
> David A. Lee
> VP Engineering
> Nexstra, Inc.
> dlee-qNp/[email protected]
> www.nexstra.com
> -------------------------------------------------------------------------
> 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
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>
> _______________________________________________
> Beanshell-users mailing list
> Beanshell-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/beanshell-users
>
>
>
>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

_______________________________________________
Beanshell-users mailing list
Beanshell-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/beanshell-users