We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › are there memory leaks in the rendering libraries
Page Index Toggle Pages: 1
are there memory leaks in the rendering libraries? (Read 587 times)
are there memory leaks in the rendering libraries?
Jan 28th, 2010, 8:03pm
 
I'm having trouble with memory leaks.  Does anybody have any advice?

My program is not very big in terms of lines of code but is somewhat complex in structure (several files that use nested classes, anonymous objects, and a little JNI).  Of course, I first assumed the problem was with my code, so I used "jhat" to check my heap.  As the system memory footprint of my running program grew from 100MB to 120MB (in under a minute), the Java heap stayed constant at about 10MB and showed nothing out of the ordinary.  And my use of JNI is dirt simple, using only base types (no allocation).

The memory leak is much worse if I use the OPENGL renderer as opposed to the JAVA2D renderer (which is a very good indicator that the problem is not in my code).  On the other hand, the memory leak seems to go away if I call "System.gc()" once or twice a second.  But this makes no sense, since Java shouldn't need me to tell it to do garbage collection!

My intuition is that perhaps there are some bugs in the native code interface to the rendering libraries that don't play well with language features like anonymous objects, and that calling "System.gc ()" while the objects are "fresh" in Java's memory ameliorates (but maybe doesn't solve) the problem.

Does anybody know anything about this?  I really want to use my code in a production environment where it will need to run for an extended period of time, and these memory leaks make me worried, even if they can be patched up with a hack like calling System.gc().

- Aaron
Re: are there memory leaks in the rendering libraries?
Reply #1 - Jan 28th, 2010, 8:50pm
 
I had a situation with a Jython, JNI, and J2EE application where I had to call the gc on the loop. I know this is a different setup. It seemed like it was a compromise to better support late-binding... the Jython bits didn't want to make any assumptions about when you might be done with the objects. That may the situation here, perhaps it didn't want to close anything because perhaps you have code somewhere else it doesn't know about that may do like shared memory or something. Anyway, a different deal to some extent, but wanted to let you know my experience. It has been working like that for several years, I have had to recycle it perhaps once every 6 months maybe, and possibly for other reasons, it has never been a low memory situation.
Page Index Toggle Pages: 1