Re: Memory leak using Beanshell.
Paul Reavis <[email protected]> Wed, 22 Oct 2008 08:27:55 -0400
| Newsgroups | gmane.comp.java.beanshell.user |
|---|---|
| Message-ID | <[email protected]> |
I've run into some memory issues as well - we have a server component with a large subcomponent that has to be restarted after a file update; this runs out of memory after several restarts. I pre-parse and re-use BeanShell scripts and for performance reasons retain a copy in memory, only loading on file change - I create an Interpreter for each of these scripts. One issue that I did resolve was that those retained interpreters had a copy of the variables passed into the script so I had to remember to clear the after a run. I'm still a little vague on some of the issues involved. My version is bsh-2.0b4 with some hacks. I found that BeanShell wasn't really designed for good performance when run repeatedly since it doesn't have an explicit compile step, and had to poke it here and there to get the behavior I needed. On Oct 22, 2008, at 1:03 AM, Atul Bisaria wrote: > Hi David and Stewart, > > Thanks for your replies. > > I am not sure of any cyclic dependencies, but on checking the > results from the Java profiling tool, I observed that int[] and > char[] objects are eating up 80% of the memory. On looking into the > beanshell APIs I observed that these objects are initialized during > the call to bsh.Interpreter.eval() method and never cleaned up or > released later until the server is stopped. > > My problem is that our application does not call beanshell APIs > directly. It invokes some of the Drools (www.jboss.org/drools/) APIs > which in turn use the beanshell APIs. I cannot make changes to the > Drools library, so in effect, I don’t have any handle from where I > can make changes to the call to bsh.Interpreter or make changes to > the finalize() call, as suggested by Stewart. > > I tried using the latest downloadable version of beanshell, i.e. > bsh-2.0b4.jar, hoping that memory leak issue is resolved in this > one, but there has been a change in some of the APIs in this version > so I can’t use it. > > Thanks and Regards, > Atul Bisaria > Senior Associate > Headstrong Services, D-4, Sector 59, Noida, India. > > > From: David A. Lee [mailto:[email protected]] > Sent: Tuesday, October 21, 2008 6:27 PM > To: Atul Bisaria; beanshell-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org > Subject: Re: [Beanshell-users] Memory leak using Beanshell. > > In my app I once had this problem. I discovered some circular > dependancies in my app which were causing beanshell to hold onto an > instance of hte interpreter. A critical point is that if any of > the rules keep an instance to any class that in turn references the > interpreter, it can consume memory in a way the GC doesnt detect. > To clean up from this, its important that you dont store multiple > references to the interpreter, especially in any objects you create > from BS scripts. Or if you do, you need to break the cycle of > referencs. To discover these, I used a Java memory tool, > JProfiler .. and looked for where the interpreter references were > being held. Its important to clear ALL references to the > interpreter when you release it or it may leak. Once I fixed that > up (no changes to BSH internals) it stopped leaking, and I can run > for months without any increase in memory use, loading scripts over > and over. > > > ----- Original Message ----- > From: Atul Bisaria > To: beanshell-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org > Sent: Tuesday, October 21, 2008 8:38 AM > Subject: [Beanshell-users] Memory leak using Beanshell. > > Hi, > > I am using Beanshell version 1.2-b3. I am using it inside Jetty > application server. Whenever I hot deploy the application, the Jetty > server does not restart but the Beanshell loads the rules file in > the application again. Repeatedly hot deploying the application is > resulting in memory leak due to Beanshell (checked it from a Java > profiling tool) and an OutOfMemory exception is thrown. > > Please let me know if there is a fix or a patch available to resolve > memory leak in Beanshell? > > Thanks and Regards, > Atul Bisaria > Senior Associate > O: +91 95120 4075267 | M: +91 9818611147 > Headstrong Services, D-4, Sector 59, Noida, India. > > > ------------------------------------------------------------------------- > 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 > ------------------------------------------------------------------------- > 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 ------------------------------------------------------------------------- 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