High memory consume saving a powerpoint with 100 slides


#1

Hello


Currently we are trying your software product for a project but when we make a concept test creating a presentation with 100 slides and 1 table on each slide we notice a lot of memory consume by the process during the save operation (I stopped it in 5GB of RAM before it blocked my laptop)

Also I used your sample code:

public class StandardTables
{
public static void Run()
{
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Tables();

// Instantiate Presentation class that represents PPTX file
using (Presentation pres = new Presentation())
{

//Access first slide
//ISlide sld = pres.Slides[0];

//PRUEBA: 1000 DIAPOSITIVAS IGUALES
for (int s = 1; s < 100; s++)
{
pres.Slides.AddClone(pres.Slides[0]);
}

for (int s = 0; s < 100; s++)
{

//Define columns with widths and rows with heights
double[] dblCols = { 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70 };
double[] dblRows = { 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70 };

//Add table shape to slide
ITable tbl = pres.Slides[s].Shapes.AddTable(100, 50, dblCols, dblRows);

//Set border format for each cell
foreach (IRow row in tbl.Rows)
{
foreach (ICell cell in row)
{
cell.BorderTop.FillFormat.FillType = FillType.Solid;
cell.BorderTop.FillFormat.SolidFillColor.Color = Color.Red;
cell.BorderTop.Width = 5;

cell.BorderBottom.FillFormat.FillType = FillType.Solid;
cell.BorderBottom.FillFormat.SolidFillColor.Color = Color.Red;
cell.BorderBottom.Width = 5;

cell.BorderLeft.FillFormat.FillType = FillType.Solid;
cell.BorderLeft.FillFormat.SolidFillColor.Color = Color.Red;
cell.BorderLeft.Width = 5;

cell.BorderRight.FillFormat.FillType = FillType.Solid;
cell.BorderRight.FillFormat.SolidFillColor.Color = Color.Red;
cell.BorderRight.Width = 5;
}
}

//Write PPTX to Disk
pres.Save(dataDir + “StandardTables.pptx”, SaveFormat.Pptx);
}
}
}
}

#2

Hi Jorge,

I have worked with the sample code shared by you and have also worked over your scenario. I have observed growing memory issue but point to consider is that there are 100 slides with 100 large tables in them. I have created an issue with ID SLIDESNET-37614 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be automatically notified once the issue will be fixed.

We are sorry for your inconvenience,


#3

Hi Jorge,

We have investigated your issue and have observed that you are saving the presentation inside a loop that is executing for 100 times. You may please move the following code line out of loop in your code.

//Write PPTX to Disk
pres.Save(dataDir + “StandardTables.pptx”, SaveFormat.Pptx);

After moving this call out the loop profiling shows that Aspose.Slides needs 200 Mb of RAM to perform all operations (creating, manipulating, saving) for presentation with table of 40 rows and 84 columns (it’s a huge one, actually) per slide. So, for presentation with 10 slides it takes 2 Gb of memory, for 100 slides - approximately 20 Gb.

This will certainly improve memory consumption issue. Moreover, we are still working over further improvement of API performance and it is a continual process. We are hopeful to improve the performance of API to a much better standard upcoming product releases till next year mid.

Best Regards,


#4

Hi,


I have the same concern as Jorge as I’m working on large powerpoint. As a workaround, we decided to split the powerpoint into 6 files.

So the logic looks something like this…

for (int i=0; i<6; i++)
{
using (Presentation pres = new Presentation(stream))
{

pres.Save…
}
GC.collect()
}

The issue now is somehow erratic. Sometimes, I get the out of memory on the 4rd save, sometimes on the 5th…

Is there a way to free up all the memory used by each instance of the presentation after it is used? the Using clause and the GC.collect doesn’t help much…

#5

Hi Marlon,

I have observed the issue shared by you and suggest you to please try using Aspose.Slides for .NET assembly available in net2.0_x64 folder of Aspose.Slides package on your end. This will give you additional memory space for your program and will help in avoiding memory exception. Please try using 64 bit dll assembly and also your project compile to x64 as well and then share the feedback.

Many Thanks,


#6

Thanks Mudassir! It works. Still slow, but it works.


#7

Hi Marlon,

It’s good to know that things have worked on your end. We are continually working on improving API performance and you will find the improvement in coming releases.

Many Thanks,


#8

Hi,
I am facing the similar issue with ppts running over 650 slides. I am using 14.8 currently tried using your latest 17.x and it still did not work. Could you please let me know if this is an aspose problem or server issue?


#9

Upto 650 slides its fine and anything over that fails due to memory constraints.


#10

@Priyarav87,

I have observed your comments. Can you please share source presentation along with sample project so that we may further investigate to help you out. I also suggest you to please try using Aspose.Slides for .NET assembly available in net2.0_x64 folder of Aspose.Slides package on your end. This will give you additional memory space for your program and will help in avoiding memory exception. Please try using 64 bit dll assembly and also your project compile to x64 as well and then share the feedback.


#11

The issues you have found earlier (filed as SLIDESNET-37614) have been fixed in this update.