Out of memory issues with Aspose Java Components

Hi,

we are using Aspose Java Components (aspose-cells-7.4.0.jar, aspose.pdf-3.3.jdk16.jar, aspose.slides-6.9.1.jar and Aspose.Words.jdk16.jar) in a Java based web-application, acting like a DAM system for Sky Italy customer.
In particular we have a “shell” process with 2 Gb of reserved memory which is in charge of the generation of preview images for the acquired documents.

For more than one year we had no particular problems, but now our users are performing massive upload operations of big Office archives and we are experiencing some severe out of memory issues, resulting in “Java heap space errors”.

By analyzing the process memory dump we found out that the 75% of the space is filled with:

89
instances of “com.sun.imageio.plugins.jpeg.JPEGImageReader”,
loaded by “” occupy 965.944.408
(75,47%)
bytes.


In attachment you can find a screenshot of the process memory usage in our test environment on which we reproduced the problem (with 1,5 Gb of memory, Aspose trial libraries and a Sun JDK 1.7.0_45-b18 64 bit), the error Stacktrace and the code used for generating document previews.


We managed to reproduce the problem by uploading the following archive twice in a row, with a few minutes break between the first and the second upload:

- 882 xls and xlsx documents (from 13 Kb to 947 Kb);
- 213 doc and docx documents (from 26 Kb to 9,5 Mb);
- 43 ppt and pptx documents (from 98 Kb to 3 Mb);
- 17 pdf documents (from 510 Kb to 16,6 Mb);


We tried to optimize garbage collecting and to update to the latest Aspose libraries, without any significant improvement.
Any help would be very appreciated since the problem is becoming quite urgent.

Thanks,
Diego

Hi Diego,

Can you please try the following in case of Aspose.Pdf and let us know if it helps in your case while processing PDF documents?

pdfDocument.freeMemory();
pdfDocument.dispose();
pdfDocument.close();

Best Regards,

Hi Muhammad,


we use only Pdf and Text objects of aspose.pdf.Pdf library (version 9.7.1), and the Pdf object has only a close() method.

In the end we managed to solve the problem by using a work-around: we now execute the Aspose logics inside an external process, so that when the process ends it also frees the allocated memory.
However, this is not the perfect solution so please let me know if you have any further suggestions.

Regards,
Diego

Hi Diego,

It looks like you are using legacy aspose.pdf.Pdf API. The mentioned methods are available in new Document Object Model if you use aspose.pdf.Document object.

If you can try the new object model, this will help us determine if these methods help in your case and we can implement the similar in other APIs.

Sorry for the inconvenience.

Best Regards,