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

Free Support Forum - aspose.com

Is there low memory use pattern for Aspose.Words?

Hi there.

I am evaluating Aspose.Words and I have the problem with OOM when saving PDF files. So far I didn't have problems with DOC and MHTML. I've read about the fact that Aspose.Words requires lots of RAM to store document being saved into memory.

I cannot divide report to small files as the available memory is keep changing, saved DOC in this example consumes 16mb and have 100k words. To create report I am using a small template which is then being populated (attached file).

Is there a way I can create and save document with the minimum memory use? Including hard coding everything?

Hi Pawel,

Thanks for your inquiry. We have just released a new version of Aspose.Words i.e. 11.10.0 here. Could you please make your tests using the latest version of Aspose.Words and let us know how it goes on your side? I hope, this helps.

In case, the problem still remains, please share your sample data source (e.g. XML data file) you’re using to generate your final reports with. I will investigate the issue on my side and provide you more information.

PS: Probably your final report document that you are trying to convert to PDF is simply too large. When you render a document Aspose.Words needs to build two model in the memory – one for document and the other for rendered document. That is why Aspose.Words utilizes more memory when you render a document than when you simply save a document in flow formats.

Best regards,


I managed to reproduce the problem with newest version of your Aspose.Words libraries (11.10). I submitted charts with memory use and gc work for DOC, MHTML and PDF formats. I also added list of your classes and instances count from heap dump just before OOM. It looks like PDF doesn't dispose data and we can see that gc is no longer able to clean memory.

I am not able to give you data I am using. I've used same data providers as for our current reporting tool and I there are no memory leaks. However if you need to know full implementation of your libraries, please let me know.

I am performing save only. Below is the bit of source code.

Document doc = new Document(getPathToTemplateDoc());
DocumentBuilder builder = new DocumentBuilder(doc);

doc.getMailMerge().executeWithRegions(createRootDataSource(builder, reportData));

File saveFile = getOutputDirFile(true);
FileOutputStream out = null;
out = new FileOutputStream(saveFile + "/test.pdf");
doc.save(out, SaveFormat.PDF);

Hi Pawel,

Thanks for the additional information. We are checking with this scenario and will get back to you as soon as possible.

Best regards,

Hi Pawel,

Thanks for your patience.

When Aspose.Words saves a document, it needs to create temporary internal structures. By default, these internal structures are created in memory and the memory usage spikes for a short period while the document is being rendered to Pdf. When saving is complete, the memory is freed and reclaimed by the garbage collector. Could you please run the following code snippet on your side and see how does the garbage collector perform on your side?
Document doc = new Document(“C:\Temp\Meteor+Template.doc”);

Section sec = (Section)doc.getFirstSection().deepClone(true);
for (int i = 0; i < 1000; i++)
sec = (Section)doc.getFirstSection().deepClone(true);


Best regards,


I performed tests as requested. Screenshots are attached. JVM is 1.6 u33.

Here is the list of JVM options:

First test got oom error.
For the second test I replaced parallel with -XX:+UseConcMarkSweepGC, however application stopped responding and I killed it after 7 mins of waiting.

What else can I do?

Cheers, Pawel

Hi Pawel,

Thanks for the additional information. Well, the code that is mentioned here worked perfectly when executing on 64-bit Windows 7 machine having java version “1.7.0_02” configured on my side. However, the same code caused a memory leak when tested on Windows XP with java version ‘1.6.0_31’. For the sake of correction, I have logged this issue in our bug tracking system. The issue ID is WORDSJAVA-662. Your request has also been linked to this issue and you will be notified as soon as it is resolved. Sorry for the inconvenience.

Best regards,

Hi Pawel,

It is to inform you that the implementation of this issue has now been postponed till a later date and we cannot push it into production right now because there are many other important issues we have to work on. Rest assured, we will inform you as soon as this issue is resolved. We apologize for your inconvenience.

Best regards,

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

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

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

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