Memory leak using Beanshell.

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Memory leak using Beanshell.

Atul Bisaria

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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|

Re: Memory leak using Beanshell.

David Lee
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 -----
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
[hidden email]
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|

Re: Memory leak using Beanshell.

Atul Bisaria

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:[hidden email]]
Sent: Tuesday, October 21, 2008 6:27 PM
To: Atul Bisaria; [hidden email]
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 -----

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
[hidden email]
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|

Re: Memory leak using Beanshell.

David Lee
I suggest taking the responses to your question and posting to the drools mailing list if there is one.
The fix needs to be made by whatever code is managing the Interpreter creation and freeing.
 
----- Original Message -----
Sent: Wednesday, October 22, 2008 1:03 AM
Subject: RE: [Beanshell-users] Memory leak using Beanshell.

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:[hidden email]]
Sent: Tuesday, October 21, 2008 6:27 PM
To: Atul Bisaria; [hidden email]
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 -----

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
[hidden email]
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|

Re: Memory leak using Beanshell.

Paul Reavis
In reply to this post by Atul Bisaria
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 [[hidden email]] 
Sent: Tuesday, October 21, 2008 6:27 PM
To: Atul Bisaria; [hidden email]
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 -----
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
[hidden email]
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
[hidden email]
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users