#329 Memory leak with WeakReferences

open
nobody
General (151)
5
2009-10-23
2009-10-23
Anonymous
No

Hello,

You have memory leak in the bsh.classpath. ClassManagerImpl. public
void addListener( Listener l ) { at
listeners.addElement( new WeakReference( l, refQueue) );

Checked with JProfiler in NetBeans.
Objects are added to listeners collection but are never removed, in
short time (with massive code execution – test stress framework) it
causes Java Heap Out of Space.
Tested with Java 1.6

Also bsh.Name and java.util.Hashtable$Entry are massively used just
like native String class!
The line in code are NameSpace.getNameResolver for java.util.Hashtable
And BSHAmbiguousName. getName for bsh.Name
You should try to tweak its memory usage, since I execute the same
code and it is not complicated, but memory foot print is huge.

Bye!

Discussion


  • Anonymous
    2011-02-27

    I can't reproduce the "ClassManagerImpl.addListener(..)" issue you describe in BeanShell2 fork at http://code.google.com/p/beanshell2 (owonload it at http://beanshell2.googlecode.com/files/bsh-2.1b0.jar ). I'll check in a unit test for this later.

    > Also bsh.Name and java.util.Hashtable$Entry are massively used just
    > like native String class!

    I'll check this later but for now from my experiences i think this could be an issue with your usage pattern. Could you provide sample code?
    You could post it here or at http://code.google.com/p/beanshell2/issues/list