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

Free Support Forum - aspose.com

SaveOptions.setTempFolder() doesn't seem to be working

We were encountering OutOfMemoryException when saving a document (generated using MailMerge). The generated document has 1350 pages, and we have a maximum heap size of 512m.

In an attempt to work around this problem, we have used SaveOptions.setTempFolder() as shown below:

String tempPath = System.getProperty(“java.io.tmpdir”);
logger.info("*** temp path: " + tempPath);
SaveOptions pdfSaveOptions = SaveOptions.createSaveOptions(SaveFormat.PDF);
File tempPDFFile = File.createTempFile(“pdfOutputStream”, “.pdf”);
OutputStream pdfBaos = new FileOutputStream(tempPDFFile);
document.save(pdfBaos, pdfSaveOptions);

However, this doesn’t seem to change anything…when monitoring the temporary folder (/tmp) we don’t see any temporary file being created (although the actual output file /tmp/pdfOutputStream.pdf is created, with a final size of about 15MB).

Also, we still see the same memory spike and continue to get OutOfMemoryError.

Is there any way we can verify that Aspose.Words is actually using a temporary file instead of building the structures in memory?

Thanks in advance.

Hi Aleem,

Thanks for your inquiry. SaveOptions.TempFolder specifies the folder for temporary files used when saving to a DOC or DOCX file.

In terms of memory, Aspose.Words does not
have any limitations. If you’re loading huge Word documents into
Aspose.Words’ DOM, more memory would be required. This is because during
processing, the document needs to be held wholly in memory.

Aspose.Words needs 10 times more memory than the original document size
to build it’s DOM in the memory and when it comes to rendering a
document to fixed page formats (e.g. PDF).

It would be great if you please share following detail for investigation purposes.

  • Please attach your input Word document.
  • Please

    create a standalone/runnable simple Java application that demonstrates the code (Aspose.Words code) you used to generate
    your output document

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

Hi Aleem,

Could you please share your input document and source code that produces OutOfMemoryException exception?