Hi,
Currently we are using aspose.slides-15.11.0 to process PowerPoint files. We have 4G RAM and 2 CPU.
But always get memory usage problem while dealing with large PPT files. When slide number goes up, memory usage keep rising ,almost consume all the memory, then CPU usage reach the top.
In order to investigate further, we use simple java code to reproduce the problem (both java 1.7 and 1.8).
package com;import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;import com.aspose.slides.ISlide;
import com.aspose.slides.License;
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;public class TestPPT
{
public static void main(String[] args) throws FileNotFoundException
{
License license = new License();
license.setLicense("/home/vincent/licenses/Aspose.Total.Java.lic");File templateFolder = new File("src/main/resources/test"); if (!templateFolder.isDirectory()) { System.out.println("Not a folder"); System.exit(1); } TestPPT test = new TestPPT(); test.processDocuments(templateFolder, 50); System.exit(0); } public void processDocuments(File folder, int passes) throws FileNotFoundException { Presentation presentation = null; int presentationNumber = 0; int slideNumber = 0; String path = folder.getAbsolutePath(); String tempPath = path + "/temp/"; for (int i = 0; i < passes; i++) { System.out.println("\nPass number " + (i < 10 ? "0" + i : i)); for (File templateFile : folder.listFiles()) { if (templateFile.isDirectory()) { continue; } System.out.println("\t# Processing template " + templateFile.getName()); if (presentation != null) { for (ISlide slide : (new Presentation(new FileInputStream(templateFile))).getSlides()) { slideNumber++; System.out.println("\t\t# Processing slides: " + (slideNumber < 10 ? "00" + slideNumber : slideNumber < 100 ? slideNumber : slideNumber)); presentation.getSlides().addClone(slide); } } else { presentation = new Presentation(new FileInputStream(templateFile)); slideNumber = presentation.getSlides().size(); } } if (((i + 1) % 10) == 0) { File tempFolder = new File(tempPath); if (!tempFolder.exists()) { tempFolder.mkdirs(); } presentationNumber++; presentation.save(tempPath + "Presentation" + (presentationNumber < 10 ? "0" + presentationNumber : presentationNumber) + ".ppt", SaveFormat.Ppt); presentation.dispose(); presentation = null; System.gc(); } } if (presentationNumber == 0) { presentation.save(path + "Presentation.ppt", SaveFormat.Ppt); presentation.dispose(); return; } else if (presentation != null) { presentation.save(tempPath + "Presentation" + (presentationNumber < 10 ? "0" + presentationNumber : presentationNumber) + ".ppt", SaveFormat.Ppt); presentation.dispose(); } processDocuments(new File(tempPath), 1); return; }
}
We tried run this test to gets all the files in that folder and joins them together to increase the size of the PPT. Iteration of the code tries to first save the presentations after 10 passes in another folder and then join them together instead of doing everything at once. This was an attempt to see if the problem was the number of files we were putting together or the actual size of the PPT. We saw no significant change between both.
(comment the if (((i + 1) % 10) == 0) block and the second call to processDocuments - processDocuments(new File(tempPath), 1); will do everything all at once)
In our test, we the slide number goes up to 1460, this java program takes 3.9G RAM and 198.7% CPU. and hanging there. We have no choice but to kill this java progress to get our resource back.
# Processing slides: 1456
# Processing template template (20).ppt
# Processing slides: 1457
# Processing slides: 1458
# Processing slides: 1459
# Processing slides: 1460
# Processing template template (39).ppt
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
23105 vincent 20 0 3329m 3.9g 17m R 188.0 30.6 127:26.47 java
Is there any solution to solve this problem or improve the performance ? Or is it fixed already ?
Please take a look at this issue, and kindly look into this as soon as possible.