Hi,
I am trying to generate a PowerPoint report using Aspose slides for .NET. I am using version 17.9. The problem started with Out of Memory exception. After the process took around 1.4 GB memory, it was failing. I was able to work around this by doing -
-
Updating Aspose.Slides.dll from 15.6 to 17.9
-
Changing my calling windows app to compile for x64
I can now generate the report just fine, but the memory used by the process just doesn’t get cleared up.
Basically I need multiple slides with tables and a small image on each slide. The data then gets filled into the tables dynamically and rows are also added dynamically. When cloning a slide to generate multiple other similar slides, the memory grows very quickly. When calling the Save method, memory usage almost more than doubles up and never gets released.
Sample code -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Aspose.Slides;
using Aspose.Slides.Export;
using System.IO;
namespace Apose_Slides_Cloning
{
class Program
{
static void Main(string[] args)
{
License license = new License();
license.SetLicense(File.OpenRead(@“C:\Aspose.Slides.lic”));
Presentation samplePPT = new Presentation(@“C:\Logs\SamplePPTX.pptx”);
using (Presentation blankPresentaion = new Presentation())
{
//ISlide templateSlide = blankPresentaion.Slides[0];
ISlide templateSlide = samplePPT.Slides[0];
ISlide templateSlideCopy = blankPresentaion.Slides.AddClone(templateSlide);
Console.WriteLine("Starting to add slides");
for (int slideIndex = 0; slideIndex < 400; slideIndex++)
{
blankPresentaion.Slides.AddClone(templateSlide);
if (slideIndex % 5 == 0)
{
Console.WriteLine("Writing slide number: - " + slideIndex);
}
}
blankPresentaion.Slides.Remove(templateSlideCopy);
blankPresentaion.Slides.RemoveAt(0);
Console.WriteLine("All slides written successfully. Starting to save presentation.");
blankPresentaion.Save(@"C:\Ayush.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
blankPresentaion.Dispose();
}
Console.WriteLine("Presentation saved successfully.");
Console.ReadLine();
}
}
}