[
https://issues.apache.org/jira/browse/XMLBEANS-283?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13267909#comment-13267909
]
Ben Foster commented on XMLBEANS-283:
-------------------------------------
I am also seeing this memory leak from code that is using v2.5. Is there any
update on this or even acknowledgment from the team?
> Creating new cursors for the same XmlObj and selecting paths leads to memory
> leak
> ---------------------------------------------------------------------------------
>
> Key: XMLBEANS-283
> URL: https://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, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]