We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Memory Leak with PresentationEx

Hi,

I am using the following code snippet in a HTTP Handler to convert a powerpoint into a collection of images:

if (filePath.EndsWith(".ppt"))
{
//.ppt = Presentation class
Presentation p = new Presentation(f);
Slides slides = p.Slides;

for (int i = 0; i < slides.Count; i++)
{
string imgPath = string.Format(@"{0}/slide{1}.jpg", directory, fileCount + i + 1);
Image b = slides[i].GetThumbnail(new Size(960, 720));
using (FileStream fs = new FileStream(imgPath, FileMode.Create, FileAccess.Write))
{
b.Save(fs, jpegCodec, encoderParams);
}
}
slides = null;
p = null;
}
else
{
//.pptx = PresentationEx class
PresentationEx pptx = new PresentationEx(f);
SlidesEx slides = pptx.Slides;

for (int i = 0; i < slides.Count; i++)
{
string imgPath = string.Format(@"{0}/slide{1}.jpg", directory, fileCount + i+1);
Image b = slides[i].GetThumbnail(1.333333333f, 1.333333333f);
using (FileStream fs = new FileStream(imgPath, FileMode.Create, FileAccess.Write))
{
b.Save(fs, jpegCodec, encoderParams);
}
}
slides = null;
pptx = null;
}
}
GC.Collect();
File.Delete(filePath);

I have 2 identical 80MB presentations, one is a .ppt, the other .pptx. They both contain a lot of images, so I understand that the IIS worker process will use up a lot of memory while I am using the Aspose library to generate my thumbnails. The problem I am seeing is that the memory is never released, even though I am explicitly setting the objects to null, and putting my filestream in a using block. I even added a GC.Collect() call at the end, even though I know that this does not ensure garbage collection.

What’s the deal? Why does the 2007 library appear to have a memory leak while the 2003 one works fine? I have seen w3wp.exe swell up to over 1 GB after running my handler a couple of times with 2007 files while the 2003 ones work fine. I understand that a lot of memory is needed while I have the presentation open, but why is it not being cleaned up after I am finished with the PresentationEx object?

I read a little bit more about this in post 58679, but is there anything else I can do with my code?

Dear Rob,

I have requested our development team to share their thoughts regarding memory leak issue and as soon as I receive some response, I will share that with you.

We are sorry for your inconvenience,