Using Aspose.Slides on Linux Container with .NET Core Does Not Release Memory

@ansamohdsh,
I’ve requested information from our developers for you. We will let you know as soon as possible.

@ansamohdsh,
We continue to investigate the cause of the problem. It has been found that in ASP.NET Core WEB API applications the garbage collector (GC) works in server mode by default. In this mode memory usage increases and it can be reserved by the process and not released to improve performance, which is what’s occurring in this instance. After switching GC to workstation mode, there was an improvement in the situation with memory consumption. To switch to workstation mode, please add the following: “false” to the .csproj project file in the section. This is one method of switching GC to workstation mode.

It has been discovered that a significant amount of memory, approximately 4.5 GB, remains occupied by objects in heap generation 2 (long-living objects) after completing all operations with the presentation (creating and saving). Objects in this heap are cleaned far less frequently. Furthermore, even after completing all operations and freeing up memory, there is no guarantee that the GC will release this memory promptly. This memory may be freed by the GC at the start of a new iteration or when memory is insufficient. Additionally, this memory can be released by calling GC.Collect (this call has been added to the method: ExportToPowerPointController.Export in your code). After switching the GC to workstation mode and invoking GC.Collect after all operations with the presentation, it was reduced memory consumption. However, we are currently investigating another issue involving the incremental increase in unmanaged memory consumption after saving the presentation to MemoryStream. This memory is not being released, leading to an increase in consumption by 280 MB with each iteration.

Currently, when creating a large presentation using your code — without saving the presentation — no increase in memory consumption is observed. It remains stable at 300 MB per iteration (with the GC in workstation mode, and memory is forcefully cleaned by calling GC.Collect after all operations).

@andrey.potapov
Thank you for sharing the information.

I have few thoughts to share:

  • As per your comment, server gc mode is by default. But according to microsoft’s documentation Garbage collector config settings - .NET | Microsoft Learn
    workstation mode is default. Also for enterprise applications like ours we do not see it ideal to switch to workstation mode as this would impact the throughput.

  • If saving the presentation file to memory stream increases the memory footprint by few Gbs, is there a way we can save the ppt to a AWS S3 bucket using aspose ppt save method?

  • calling GC.Collect is also not a ideal way, as its a framework level garbage collection which ideally framework should handle.

  • With each iteration, without saving the presentation, why does the memory increase?

Do you have any further updates for us?

@ansamohdsh,
I’ve forwarded your questions to our developers.

@ansamohdsh,
We have resolved the issue of gradual memory increase during each iteration of saving the presentation to MemoryStream. We also tested the solution with your sample code, and no memory increase was observed. Your scenario was run 150 times during the testing. The fix will be available in version 23.10. This release will be published in the second half of October.

thank you @andrey.potapov for the update.
We will incorporate the fix once it it available from your side and try to stimulate our scenario and understand the memory issues further.

Do keep us posted on release date.

@ansamohdsh,
You will be notified when the release is published. Thank you for your patience.

@ansamohdsh,
We found an issue with the solution. We will fix it and provide the fixed package as a hotfix. Thank you for your patience.

@andrey.potapov Thank you for the update.
Please let us know when the hotfix would be available? Any tentative timeline?

@ansamohdsh,
I’ve requested the tentative timeline for the hotfix from our developers. We will let you know soon.

@ansamohdsh,
We have identified the cause of the issue and are currently working on a solution. The ETA is next week.

The issues you found earlier (filed as SLIDESNET-43994) have been fixed in Aspose.Slides for .NET 23.10 (ZIP, MSI).
You can check all fixes on the Release Notes page.
You can also find the latest version of our library on the Product Download page.

@ansamohdsh,

This notification was sent by mistake. We apologize for any inconvenience. We are waiting for the hotfix from our developers.

@andrey.potapov Any update on the fix release date? We are nearing the end of October Month.

@ansamohdsh,
As far as I can see, our developers are reviewing a solution. The ETA is still this week. Thank you for your patience.

hi @andrey.potapov
Please help us understand the resolution timelines. It has been pending for quite sometime now.

@ansamohdsh,
As far as I can see, the issue has been resolved. I’ve requested a timeline for the hotfix from our developers. We will let you know shortly.

@ansamohdsh,
Our developers will do their best to provide Aspose.Slides for .NET with the hotfix as a ZIP package tomorrow.

@andrey.potapov
Hi, I do not see any hotfix yet, when can we expect the hotfix ?

@ansamohdsh,
I’m still waiting for the hotfix from our developers and will provide it to you as soon as possible.