Presentation.Slides.InsertClone Method Never Releases Memory


We have an issue while merging a large set of PowerPoint files >800). We are getting Out of Memory exception and we have some questions and findings which might help you to find the culprit.

Please find the attached sample project here. (150.2 KB)

Here is the video of the observation we did just using two simple pptx files for merge operation.

Steps to Monitor Increase in MemorySize after adding each slide from one presentation to another:

  1. First create the folders and files in the file path mentioned in the UI textbox, in order to use later for merge operation.
    DestinationFolder should contain Images Folder and Books Folder and pptx files to be merged, all these folders and files are attached here.( (134.0 KB)
    Note: These folders and files inside Images are necessary, else you need to modify the code to avoid IO exception

  2. Then Run the project and observe and Note Down the Memory before Merge Operation, in task manager or using Visual studio Diagnostic tools.

  3. click on the “Generate PowerPoint Book” and note down the memory now.

Both pptx files are around 82Kb in size, but the process takes around 10 to 18 Mb memory for overall merge operation(2 files). Is this expected behavior or a bug?

As of now we are merging only two files, but as you increase the input size(>800 pptx files), Memory grows > 3.8GB and finally throws Out of memory exception. We believe there is something fundamentally wrong during this merge operation itself, as it stacks memory around 1-3Mb, each time when we add slides from source files(of 82kb size) to destination and that is never released. If you just call GC.Collect() and GC.WaitForPendingFinalizers(), after merging each file, memory doesn’t get stacked.

Also, if you want to dig deeper , put a breakpoint where we actually insert the slide((BookPowerPointManagerAspose.cs=> MergePowerPointFiles() => Line No. 143)) OR where we create the Presentation objects and monitor the memory jump, When the pptx file itself is around 82Kb, why does the memory jumps around 1-3Mb, why it holds such amount of memory?

You can also see the memory consumption is way heigher(2x) than the actual pptx file itself in other parts of the sample(like where we load the file after merging and copy the file etc). If you use >800 files for merging , you can see this difference clearly. Not sure is this expected or a bug, please review.

We are aware that some of the aspose.slides objects has to reside in cache to improve performance, but the amount of cache memory compared to the actual pptx file size during merge operation looks too high(10x) for us. Hope it might help you to find the culprit.

We have licensed Aspose.Slides from past one year and this is the only critical issue that we are facing so far. So Please review and let us know as soon as you can as this bug exists in our production. Our customers cannot merge large number of files due to this issue.


Thank you for describing the issue.

I’ve added a ticket with ID SLIDESNET-43600 to our issue-tracking system. Our development team will investigate the case. We will inform you of any progress.