Free Support Forum -

Getting Java Out of memory using Aspose Slides java lib

Hi there,

I am getting out of memory error when I am trig to write to a stream.
This is my code…
FileOutputStream fOSPresentation = new FileOutputStream(new File(fileName + “.ppt”));
Presentation newPresentation = new Presentation();

I am getting Out of memory error at line newPresentation.write(fOSPresentation);
I am getting this even if I use the
newPresentation.write(String fileName) method;

Stack says

java.lang.OutOfMemoryError: Java heap space
at com.aspose.slides.Presentation.else(SourceFile:908)
at com.aspose.slides.Presentation.write(SourceFile:698)

Is this a known issue? Has there been any release that fixes this issue ?
The input PPT is around 16MB and has many images. Though I may not be able to share the actual PPT, I have a sample PPT where I can reproduce this and share with you.

Kiran. M

Hi Kiran,

Thanks for your interest in Aspose.Slides.

I have checked the code snippet provided by you and it is working fine. In my observation, the size of presentation that you are trying to write in the file is exceeding the heap size and causing a runtime exception. I can offer a suggestion that you need to increase your heap size. Please, follow the command line below and adjust the heap size values as per your requirements, while executing a java class file.

java -Xms -Xmx JavaApp

Defaults are:

java -Xms32m -Xmx128m

Thanks and Regards,

Hi All,

Why did the API method (Presnetation.write()) write the whole stream in one shot ? Or does this internally loop / use buffered stream to ensure that the whole thing is not dumped in one shot.
And unfortunately couple of our PPTs are going to be huge.

Kiran. M

Hi Kiran,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for considering Aspose.Slides.

It is not possible to write PPT format to stream without preparing whole structure in the memory for Presnetation.write() method . So, increasing the heap size is the only solution for reading large presentations.

We are sorry for the inconvenience.