Memory leak when loading and saving Presentation


#1

When using the Slides Presentation, Presentation is not getting garbage collected. See attached .NET application that does an open of a simple pptx file and saves it to a file stream. This is problematic in server deployment and larger files as it eventually causes out of memory conditions. See attached project for scenario where this occurs.

https://drive.google.com/open?id=1sAe0A8BLKNvnh0njYYTqQZH8iQIZIVy7


#2

@clarksrjey,

I am unable to access file shared by you. Can you please grant access to files so that we may further investigate to help you out.


#3

Were you able to get the file? Any status?


#4

@clarksrjey,

I have worked with source file and created investigation ticket. A ticket with ID SLIDENET-41489 has been created in our issue tracking system for further investigate this in detail. This thread has been associated with this ticket, so that you can be automatically notified as soon as this issue is resolved.


#5

Is there any status on this? We need to get this memory leak fixed so that we can move to production.


#6

@clarksrjey,

I like to inform that we have tested this in our end and modified example a bit and process presentation load-save routine in a loop. We modified the code snippet and add for loop

(" for (int index = 0; index < 1 ; index++) { … } "):

I like to inform that after running loops for different values we are always getting almost the same TotalMemory metric value. Can you please test it in your environment.

Console.WriteLine($"Before Create Presentation - GC.GetTotalMemory() = {GC.GetTotalMemory(true)}");

for (int index = 0; index < 1  ; index++)
{
    using (Presentation pres1 = new Presentation(FileName))
    {
        if (File.Exists(NewFile))
        {
            File.Delete(NewFile);
        }

        using (var rawStream = File.Open(NewFile, FileMode.OpenOrCreate, FileAccess.ReadWrite))
        {
            var format = GetSaveFormat(ref FileName);

            Console.WriteLine($"Before Save - GC.GetTotalMemory() = {GC.GetTotalMemory(true)}");
            pres1.Save(rawStream, format);//, so);
            Console.WriteLine($"After Save - GC.GetTotalMemory() = {GC.GetTotalMemory(true)}");
        }
    }
}

GC.Collect(2, GCCollectionMode.Forced, true);
GC.WaitForPendingFinalizers();