Re: Memory leak using Beanshell.

"Atul Bisaria" <[email protected]> Wed, 22 Oct 2008 10:33:25 +0530
Newsgroups gmane.comp.java.beanshell.user
Message-ID <DC56F5EE9CF5174581E6CBACBD803D5407426CBC@hsnda2ksexch03.noida.headstrong.com>
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/
<http://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 <mailto:[email protected]>  

	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