Free Support Forum - aspose.com

OutOfMemoryError when opening word document

Hi,


The attached word document causes a OOME when opened with Aspose Words. Here is some sample code to reproduce the problem:

package com.test.app;

import com.aspose.words.Document;

public class App
{
public static void main( String[] args ) throws Exception
{
Document document = new Document("/path-to-file/Analysis of SQL Servers performance.docx");
System.out.println(document.getPageCount());
}
}

If you set the -Xmx flag to 2g you will see the program runs for several mins and then throws a OOME. If I set the Xmx all the way up to 4g it will work, but this is not a practical solution for us. If the document is too “hard” to open then we are happy for this to fail, but it needs to happen in a more controlled way. Throwing an OOME brings our whole system down. The solution we need is either:

a) A way of detecting that the document is to “hard” to open before we even try

or

b) Have Aspose fail in a more graceful way that does not take down the whole system.

Cheers.

Hi there,

Thanks for your inquiry.

atlassian:

a) A way of detecting that the document is to “hard” to open before we even try
or
b) Have Aspose fail in a more graceful way that does not take down the whole system.

I suggest you please use the same code in try catch block and handle the exception.

I
have tested the scenario and have managed to reproduce the same issue
at my side. For the sake of correction, I have logged this problem in
our issue tracking system as WORDSNET-10951. I have linked this forum
thread to the same issue and you will be notified via this forum thread
once this issue is resolved. We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-10951) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Hi Aspose,

Could you give me more information? What is the result of your fix?

My test results:
- With -Xmx256m:
+ 13.12.0.0: Fail after 17 seconds
+ 15.7.0: Fail after 4 seconds
- With -Xmx512m:
+ 13.12.0.0: Fail after 15 seconds
+ 15.7.0: Fail after 3 seconds.
- With -Xmx1024m:
+ 13.12.0.0: Fail after 60 seconds
+ 15.7.0: successful

So, with the fix, fail quicker and use memory more effectively?

Thanks,

Hi there,

Thanks for your inquiry. Yes, we have made performance improvements during transition from 13.9.0 to 15.7.0. Please note that performance and memory usage all depend on complexity
and size of the documents you are generating. While rendering a document to fixed page formats (e.g. PDF), Aspose.Words needs to build two model in the memory – one for document and the other for rendered document.

The process of building layout model is
not linear; it may take a minute to render one page and may take a few
seconds to render 100 pages. Also, Aspose.Words has to create APS (Aspose Page Specification)
model in memory and this may again eat some more time for some
documents. Rest assured, we’re always working on improving performance;
but, rendering will be always running slower than simple saving to flow
formats (e.g doc/docx).