We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Memory issue when appending documents

Hi,


i’m using the latest aspose library for a client, and i’m working on a webapplication that, at some point, take a whole bunch of docx and merge them into a single document.
The docx are individually stored on the fs, so the procedure goes like this:

ArrayList documentsNames; //here are the filenames Document finalDoc = new Document();
for(String documentName : documentsNames){
Document docToMerge= new Document(documentName); finalDoc.appendDocument(documentName);
}

Nothing particularly fancy, but with around 200+ docs i'm having big memory problems, in the sense that i get a heap space exception.

I analized the heap content and i found out that i have thousands of Sections object in it. This happens even if i declare the docToMerge outside the for loop, and set it to null after appending it.

Is there any way to clear the memory used? I already have a heap size of 2G and now i'm simulating working with only one user, but in production mode there will be many more...

Thanks a lot!

Sorry i forgot to mention one important thing: the documents are about 50-60 kb each, and the final document a couple of mbs…

Hi there,


Thanks for your inquiry. Please note that the memory may not be released until a process is completed. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word documents
  • Please create a standalone Java application (source code without compilation errors) that helps us reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip them and Click ‘Reply’ button that will bring you to the ‘reply page’ and there at the bottom you can include any attachments with that post by clicking the ‘Add/Update’ button.

Hello,


i did some more testing and i found out that the problem is not a memory leaking, just the huge amount needed by aspose library combined with the container (glassfish).
One of my analisys (consisting in making a 10 lines standalone java program that takes all the 1000 circa 10-20 kbs docx in a folder and combines them in a final one) revealed this: it seems that the garbage collector actually keeps ignoring the “old gen” object referring to old docs, so the heap space stays high.

Hope this helps!

Hi there,


Thanks for your inquiry. Unfortunately,
it is difficult to say what the problem is without the Document(s) and
simplified Java application. We need your Document(s) and simple project to
reproduce the problem. Moreover, please share the environment detail e.g Operating System, Jdk version, web server detail.

As soon as you get these pieces of information to us we’ll start our investigation into your issue.