Aspose.Slides for Java Consumes a Lot of Heap Memory and Causes HeapOutOfMemory Problem

On a machine with 4GB RAM and RHEL 9.2 OS. We have out webapp configured with -Xms1024m configuration for JVM. When we are processing PPT/PPTX files we encountered sudden memory usage shoot up which inturn results into HeapOutOfMemory problem and Server crashes.

This is even observed on basic PPT/PPTX files with size less than 200kB.

We tried the same scenario on system with 4GB RAM and RHEL 8.8 OS and issue is reproducible on same.

What are we doing with presentation files?
→ We are getting the document properties, setting some custom properties, and saving the files. The Heap Space issue is observed while saving the files.

We are facing this issue only on linux systems and not on Windows System.

We have tried Aspose-slides for java 23.12 and 24.1 and we have observed the issue with both.

Also we see following WARNING messages in our Web Server logs:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.aspose.slides.internal.ox.d0 (file:/opt/seclore/decryption-server/decryption-server/WEB-INF/lib/aspose-slides-24.1-jdk16.jar) to method sun.font.FontUtilities.getFont2D(java.awt.Font)
WARNING: Please consider reporting this to the maintainers of com.aspose.slides.internal.ox.d0
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

@poladiaraj,
Thank you for contacting support.

To investigate the case and help you, we need more details. Please share the following files and information:

  • sample presentation files
  • code example or sample project
  • stack trace of the error
  • JDK version in your app

These warnings have been added to JDK since version 9. Please note that these are warnings, not errors. You can use the following JVM option to suppress these messages: --add-opens
https://docs.oracle.com/javase/9/migrate/toc.htm#JSMIG-GUID-7BB28E4D-99B3-4078-BDC4-FC24180CE82B

======================== Java Version ==========================
Adopt JDK 11.0.19+7

======================== Stack Trace ===========================

Feb 09, 2024 12:10:37.946 : http-nio-8080-exec-1 : ERROR : Java heap space| Correlation ID : ee2446ee-5f41-4e41-9143-9e0fb8fb1b3b Java heap space
java.lang.OutOfMemoryError: Java heap space
at com.aspose.slides.Collections.Generic.Dictionary.hn(Unknown Source)
at com.aspose.slides.Collections.Generic.Dictionary.cl(Unknown Source)
at com.aspose.slides.Collections.Generic.Dictionary.set_Item(Unknown Source)
at com.aspose.slides.internal.gw.m2.v2(Unknown Source)
at com.aspose.slides.internal.i1.hn.v2(Unknown Source)
at com.aspose.slides.internal.gw.hn.v2(Unknown Source)
at com.aspose.slides.internal.gw.gv.xz(Unknown Source)
at com.aspose.slides.internal.gw.gv.v2(Unknown Source)
at com.aspose.slides.internal.gw.gv.v2(Unknown Source)
at com.aspose.slides.internal.gw.gx.v2(Unknown Source)
at com.aspose.slides.internal.gw.gx.hn(Unknown Source)
at com.aspose.slides.internal.gw.gx.v2(Unknown Source)
at com.aspose.slides.internal.gw.co.v2(Unknown Source)
at com.aspose.slides.ql.v2(Unknown Source)
at com.aspose.slides.ql.v2(Unknown Source)
at com.aspose.slides.ql.v2(Unknown Source)
at com.aspose.slides.ql.v2(Unknown Source)
at com.aspose.slides.nc.v2(Unknown Source)
at com.aspose.slides.vpv.v2(Unknown Source)
at com.aspose.slides.nc.v2(Unknown Source)
at com.aspose.slides.iv.v2(Unknown Source)
at com.aspose.slides.p5.v2(Unknown Source)
at com.aspose.slides.kxc.ov(Unknown Source)
at com.aspose.slides.tf.v2(Unknown Source)
at com.aspose.slides.jne.v2(Unknown Source)
at com.aspose.slides.jne.v2(Unknown Source)
at com.aspose.slides.iqn.v2(Unknown Source)
at com.aspose.slides.iqn.v2(Unknown Source)
at com.aspose.slides.iqn.(Unknown Source)
at com.aspose.slides.xp5.v2(Unknown Source)
at com.aspose.slides.ncg.v2(Unknown Source)
at com.aspose.slides.ncg.v2(Unknown Source)

======================== Sample Code ===========================

try
{
	Presentation lslides = new Presentation(strFilePath);
	IDocumentProperties lDP = lslides.getDocumentProperties();

	if(lDP.containsCustomProperty("PolicyServerId_FS"))
	{
		lDP.removeCustomProperty("PolicyServerId_FS");
	}

	lDP.setCustomPropertyValue("PolicyServerId_FS", "Policy Server ID");

	lslides.save(strFilePath, com.aspose.slides.SaveFormat.Pptx); //Heap Space issue during this operation
}
catch(Exception lException)
{
	//Handled Exception
}

==================== Sample Presentation File ==================

A simple PPTX File with 1 slide and some text content on it.
Sample.zip (24.9 KB)

@poladiaraj,
Thank you for the details. Unfortunately, you forgot to attach the sample presentation file. You can zip the file and upload an archive here.