Memory Leak Occurs when Instantiating and Disposing a Presentation Object in Java

Hello, I found that after instantiating presentation, even after the presentation.dispose () method was called, the memory usage of the jvm was still high and memory was not freed. In my debugging, I found that this part of memory leakage may come from power point embedded fonts. Font memory was not correctly released by dispose() method every time. Is there any way to release this part of memory

@DNic,
Thank you for contacting support.

Please check your results using the latest version Aspose.Slides for Java if it is possible. If the issue persists, please share the following files and information:

  • sample presentation file (you can zip the file and upload an archive here)
  • code example you used
  • OS version on which the code was executed
  • JDK version in your app
  • Aspose.Slides version you used
  • screenshot showing the memory leak
  • any additional information about your environment

Thank you for your reply. I am using the latest version of Aspose.slides 23.5, and the code runs on windows10,jdk1.8 and power point2019. In the code, I prepared five power point files, embedded all fonts used in the file Settings, and then disposed five files after instantiation by loop. I called the java memory usage method and printed out the memory usage after gc. Each presentation object leaked 60mb of memory on average. I have also found that memory leaks do not occur when fonts are not embedded in the power point file Settings. So I suspect this part of the leak is caused by loading fonts

String path = "E:\\testDemo";
File file = new File(path);
File[] files = file.listFiles();

MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
MemoryUsage memoryUsage = memoryMXBean.getHeapMemoryUsage();
long usedMemory = memoryUsage.getUsed();
System.out.println("before used:" + usedMemory + " bytes");

for (int i = 0; i < files.length; i++) {
    Presentation presentation = new Presentation(files[i].getAbsolutePath());
    presentation.dispose();
    presentation = null;
    System.gc();
}

memoryMXBean = ManagementFactory.getMemoryMXBean();
memoryUsage = memoryMXBean.getHeapMemoryUsage();
usedMemory = memoryUsage.getUsed();
System.out.println("after used:" + usedMemory + " bytes");

before used:13596568 bytes
after used:323539768 bytes

Files exceeding 50mb cannot be uploaded

If it cannot be resolved, the memory leak is fatal on the server and cannot be applied on the server, subscribing to Aspose.slides will not make any sense

@DNic,
Thank you for the additional information.

To investigate the case on our end, we need the sample presentations. Please share a link to the files saved to a file storage (Google Drive, Dropbox, or other).

This is the power point file I tested

@andrey.potapov

@DNic,
Thank you for the details. I reproduced the problem you described.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): SLIDESJAVA-39209

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@DNic,
The issue will be resolved in Aspose.Slides for Java 23.6. This release will be published in the second half of June. You will be notified.

The issues you found earlier (filed as SLIDESJAVA-39209) have been fixed in Aspose.Slides for Java 23.6 (JAR).
You can check all fixes on the Release Notes page.
You can also find the latest version of our library on the Product Download page.