You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xmlbeans.apache.org by "Tero Vuorela (JIRA)" <xm...@xml.apache.org> on 2006/08/10 13:07:14 UTC
[jira] Created: (XMLBEANS-283) Creating new cursors for the same
XmlObj and selecting paths leads to memory leak
Creating new cursors for the same XmlObj and selecting paths leads to memory leak
---------------------------------------------------------------------------------
Key: XMLBEANS-283
URL: http://issues.apache.org/jira/browse/XMLBEANS-283
Project: XMLBeans
Issue Type: Bug
Components: Cursor
Affects Versions: Version 2.2
Environment: Java 1.4.2_10, Windows XP
Reporter: Tero Vuorela
Priority: Minor
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 )
{
// if xmlObj would be created here then there wouldn't any leak
//XmlObject xmlObj = XmlObject.Factory.parse( "<test>foobar</test>" );
XmlCursor cursor = xmlObj.newCursor();
cursor.selectPath( "*" );
// in this example case we don't do anything for selected elements
cursor.dispose();
}
}
}
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.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org