Exception: OutOfMemory on generating slide thumbnail (C# .NET)

Hi,

Very interesting problem. I have two powerpoint files. One is a general one I created with the latest Office 365 PowerPoint (9 slides, 3MB), and another I downloaded from the web (50+ slides, 3 MB). If I try to get the screenshot of the slides using the built in function GetThumbnail(1.0F, 1.0F)), one works, the other with the 50+ slides blows up like crazy, memory usages goes thru the roof. 100 mb/per slide and eventually runs out of memory.

Code:

                    billboardBytes = File.ReadAllBytes(FileOpenDialogBillboard.FileName)

                    ' Convert PowerPoint to images and load the image slider.
                    Using stream As MemoryStream = New MemoryStream(billboardBytes)
                        Using powerPoint As Presentation = New Presentation(stream)
                            For index As Integer = 0 To powerPoint.Slides.Count - 1 Step 1
                                billboardSlider.Images.Add(powerPoint.Slides(index).GetThumbnail(1.0F, 1.0F))
                            Next
                        End Using
                    End Using

We own Aspose.Slides for .NET version 17.7, and tried it also with 20.2. Same thing happens.

The powerpoint that blows up is from this link.

@support.jbdev,

I have worked with sample presentation shared by you using Aspose.Slides for .NET 20.2 on my end and have not been able to observe the issue specified. I have used x64 based application on my end and observed no issue on my side. I have attached the output as well for reference.

Images.zip (3.4 MB)

Thanks for the reply, I appreciate it!

Can you try using a x86 application sample application, my app fully loaded is about 250 MB in memory. As soon as the first GetThumbnail() executes, it jumps to 300, then the next is 450 MB, after the sixth call it goes to 1 GB and crashes there. I can try x64 and see if it makes a difference and post my results.

Sadly I can’t try it in x64 since our app cannot handle it, we still have DLL’s of other components that are 32 bit only.

@support.jbdev,

I have observed your requirements and like to share that it is not an API issue. You are getting exception owing to reason that required program memory is not sufficient enough. Your presentation has got 58 slides. The amount of program memory required is not dependent upon the size of presentation only. The number of slides, the number of shapes inside each slide, the content inside shape especially multimedia content. This all gets loaded in program memory inside Document Object Model (DOM) of Aspose.Slides. In your case there are 58 slides with rich shapes and contents. Apart from that you are performing rendering of slide too on your end which require additional program memory. Therefore, you are facing this limitation. I hope the shared elaboration will be helpful.

Hi,

There is definetly something wrong. I created a simple project. I ran it in 64 bit, with the same powerpoint, which is 3MB in size. The memory usage until it finished went up to 2.5 GB for the application. There must be a memory leak somewhere. The GetThumbnail should get the image per slide, so it should not retain data from a pervious slide.

@support.jbdev,

I have created and x86 based sample project on my end and that too has no issue in generating slide thumbnail on my end. I am using VS 2019 on Windows 10 with a very old machine and still there is no issue. I doubt there is any memory leak here and If you think there may be any, please share some evidence with us that we may consider and test accordingly on our end.

TestSlidex86.zip (16.4 KB)

image.png (63.5 KB)

Hi,

Attached is my project. Go into the bin folder, and under x86 or x64 the binaries are there run. The source code is there too, to check it out, but won’t be able to compile it since it requires DevExpress components for the image slider.

Now i am wondering if the difference is that I am storing the returned bitmap in a image slider collection, not saving it out to file disk. But why would that make a different? I will be doing more tests, let me know what you think about my project. When you run the apps, have Task Manager open and see the memory usage spike.

Link to project:

https://6563-my.sharepoint.com/:u:/g/personal/lenb_jbdev_com/EXQkZy97sYtLpFHuWvYS_3EBzRUJfSlzT5e1JjuNSJr90A?e=KbmYt9

Expires on the 1st.

I am also using VS 2019 (latest patch) and Windows 10 64 bit 1909 (latest). I noticed on yours the memory stays consistent to 190-220 MB for each iteration. Mine just climbs and climbs and climbs till the sky, to 2.5 GB of memory usage. My guess might be is that i am retaining the bitmaps coming back in a collection. Just have to find out why…

Thanks for helping by the way, I appreciate the feedback.

So far if I create a Console app, it works in either VB or C#, even if I save or I retain the images in a List. However, as soon as the code is in a WinForm application it poops up :slight_smile:
Same code, different project types. I also tried different .NET framework versions, it didn’t help. I will try another laptop this afternoon see if I can reproduce it there, but so far I am finding WinForms to be the culprit. I will keep you posted.

@support.jbdev,

Thank you for your valuable feedback. I hope you will be able to narrow it down further on your end with further testing on different machine.

I tested it on a laptop and also on a server, both blew up with memory when using that PowerPoint. Not sure what to do at this point…

Were you able to see if my project worked for you?

@support.jbdev,

Please provide a complete sample project that I may test and use on my end to reproduce the issue. Based on sample code you provided, I created a project my self and was unable to reproduce the issue. Therefore, in order to proceed fuhrer, we require a working Visual Studio sample project that is failing on your end.

I can provide a project. However you can just run the application from the bin folder by running the .exe. I just wanted to see if it did the same thing on your machine as on mine. I will try to get a project together.

2020-03-16_12-57-46.zip (7.9 MB)

Attached is a video of what is happening. If you have time can you review it?

Attached is a small application using only WinForm controlles. Image Test.zip (16.6 KB)

@support.jbdev

I have worked with sample project share by you and have ran the exe file in your project. There is no issue on execution on my end.

image.png (5.9 KB)

I believe you are using .net core, my project is a WinForm application, using .NET Framework 4.8. Attached are videos of the project in Visual Studio and also running on Windows Server 2016, on both machines the memory blows up. Same code in Console app do not. But they do when used in a WinForm project.

Videos.zip (8.1 MB)

@support.jbdev,

You are right that issue is only reproduced specifically in Win Forms application running on .NET Framework 4.8. I have been able to reproduce the issue while generating slide thumbnail of slide 26. An issue with ID SLIDESNET-41824 has been created in our issue tracking system to further investigate the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.