Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Tue Dec 12, 2023 2:23 am

I use the following code to open ppt in winui3, export a picture and then close it. The size of ppt is greater than 1G, the memory will occupy more than 1G, and the memory will not be released after execution. Could you please help me see where there may be problems in the code?
Word and Excel also have the same phenomenon.

Code: Select all
private void ButtonPpt_Click(object sender, RoutedEventArgs e)
{
    try
    {
        System.Drawing.Image image = null;
        using (Spire.Presentation.Presentation presentation = new Spire.Presentation.Presentation())
        {
            presentation.LoadFromFile(@"E:\文档\颁奖胶片.pptx");
            for (int i = 0; i < presentation.Slides.Count; i++)
            {
                image = presentation.Slides[i].SaveAsImage();


                break;
            }

            presentation.Dispose();


        }
           
       

        BitmapImage bitmapImage = new BitmapImage();
        using (MemoryStream stream = new MemoryStream())
        {
            image.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
            stream.Position = 0;
            bitmapImage.SetSource(stream.AsRandomAccessStream());
        }
        ImageTest.Source = bitmapImage;

        image.Dispose();
        image = null;
    }
    catch (Exception ex)
    {

    }
}

vance2023
 
Posts: 2
Joined: Tue Dec 12, 2023 2:14 am

Tue Dec 12, 2023 3:50 am

Hello,

Thank you for your inquiry.
Based on your description, if your PPT file size exceeds 1GB, our product may generate a significant number of objects and font information during document loading and parsing, leading to substantial memory consumption.
Regarding the issue you mentioned about memory not being released after using "presentation.Dispose()", please be aware that the Dispose() method is designed to release objects and free memory. However, the actual memory cleanup is managed by the system's garbage collection mechanism, not controlled by our product. Typically, the system takes care of cleaning up and releasing freed heap memory after the process has ended.
Additionally, you can also invoke the system's garbage collection method to forcibly reclaim the Presentation object.
Thank you for your understanding.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Tue Dec 12, 2023 7:19 am

Thank you very much, if it is released after the program ends, it does not work well on my side.
Annika.Zhou wrote:Hello,

Thank you for your inquiry.
Based on your description, if your PPT file size exceeds 1GB, our product may generate a significant number of objects and font information during document loading and parsing, leading to substantial memory consumption.
Regarding the issue you mentioned about memory not being released after using "presentation.Dispose()", please be aware that the Dispose() method is designed to release objects and free memory. However, the actual memory cleanup is managed by the system's garbage collection mechanism, not controlled by our product. Typically, the system takes care of cleaning up and releasing freed heap memory after the process has ended.
Additionally, you can also invoke the system's garbage collection method to forcibly reclaim the Presentation object.
Thank you for your understanding.

Sincerely,
Annika
E-iceblue support team

vance2023
 
Posts: 2
Joined: Tue Dec 12, 2023 2:14 am

Tue Dec 12, 2023 9:57 am

Hello,

Thank you for your feedback.
I have submitted the issue you reported to our development team with the reference number SPIREPPT-2403. They will investigate and work on fixing it. Once it is resolved, I will inform you in time. Sorry for the inconvenience caused.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.Presentation