Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
Version 2.2
-
None
-
None
-
Java 1.4.2_10, Windows XP
Description
I have a reference to XmlObject that I like to keep while my application is running. During run new cursor for the XmlObject is created many times and selectPath(..) is called for the cursor. I call dispose() when I'm finished with the cursor. However using a profiler I can see that Cursor object are not garbage collected. If XmlObject would be unreferenced then all cursors would be garbage collected.
Here is an example code:
public class XmlBeansTest
{
public static void main( String[] args )
throws Exception
{
XmlObject xmlObj = XmlObject.Factory.parse( "<test>foobar</test>" );
while ( true )
}
}
Above code results to increasing amount of Cursor objects. If xmlObj is created inside loop there would be any problem.
Checking the code it seems that ChangeListener structure is Cursor and Locale classes keep references alive. The problem occurs if selectPath() is called because _selectPath calls Locale.registerForChange(..) that builds up ChangeListener "linked list".
I wonder if it could be possible to clear _nextChangeListener when calling dispose() or some other way to tear down ChangeListener structure. I'm not familiar with XmlBeans code so I don't know what could be side effects of that change.