incubator-odf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mathias Silbermann (Issue Comment Edited) (JIRA)" <j...@apache.org>
Subject [jira] [Issue Comment Edited] (ODFTOOLKIT-300) Memory Leak in ODF Simple API
Date Tue, 07 Feb 2012 07:36:59 GMT

    [ https://issues.apache.org/jira/browse/ODFTOOLKIT-300?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13202143#comment-13202143
] 

Mathias Silbermann edited comment on ODFTOOLKIT-300 at 2/7/12 7:35 AM:
-----------------------------------------------------------------------

Hi,

the piece of code that lead to the leak is this one:

        TextNavigation match = new TextNavigation(replacementMark, this.templateDocument);
        
        while (match.hasNext())
        {
            TextSelection selection = (TextSelection) match.nextSelection();
            selection.replaceWith(replacement);
            selection.freeResources();
        }

I did a for-loop with 1000 cycles where I loaded the same odt-document in each cycle using:

       this.templateDocument = TextDocument.loadDocument(this.templateFilePath);

After opening a document, I replaced many words using the first piece of code for each word
to be replaced.
In the end of each cycle, I saved the document using

       this.templateDocument.save(out);

You can use jConsole to see the growing memory consumption of the jvm running the 1000-cycle
loop.
                
      was (Author: silbermann):
    Hi,

the piece of code the lead to the leak is this one:

        TextNavigation match = new TextNavigation(replacementMark, this.templateDocument);
        
        while (match.hasNext())
        {
            TextSelection selection = (TextSelection) match.nextSelection();
            selection.replaceWith(replacement);
            selection.freeResources();
        }

I did a for-loop with 1000 cycles where I loaded the same odt-document in each cycle using:

       this.templateDocument = TextDocument.loadDocument(this.templateFilePath);

After opening a document, I replaced many words using the first piece of code for each word
to be replaced.
In the end of each cycle, I saved the document using

       this.templateDocument.save(out);

You can use jConsole to see the growing memory consumption of the jvm running the 1000-cycle
loop.
                  
> Memory Leak in ODF Simple API
> -----------------------------
>
>                 Key: ODFTOOLKIT-300
>                 URL: https://issues.apache.org/jira/browse/ODFTOOLKIT-300
>             Project: ODF Toolkit
>          Issue Type: Bug
>          Components: simple api
>    Affects Versions: 0.8.7
>         Environment: odfdom-java-0.8.7.jar; simple-odf-0.6.6.jar
>            Reporter: Mathias Silbermann
>            Assignee: Devin Han
>
> There is a memory leak in the ODF Simple API. I tried both, versions 0.6.6 and 0.6.5.
It appears when running code like the examples on cookbook page
> http://incubator.apache.org/odftoolkit/simple/document/cookbook/Manipulate%20TextSearch.html
> In short, the call TextNavigation.nextSelection() leads to the leak. When you look down
the method's call stack, you will find that items are added to the static variable "repository"
of the static inner class "Selection.SelectionManager". The added items are never removed
from the repository. One indication is that the method Selection.SelectionManager.unregisterItem()
is never called.
> The code works fine if text navigation is done with few documents. But when its run on
a server thousands of times, it will fill the JVMs memory.

--
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

        

Mime
View raw message