I have tried upgrading to the latest Spire.Presentation 8.2.0 but I am still encountering an issue where some of the memory are not cleared after creating the Spire objects even after I have disposed them.
Here is a sample of our memory snapshots:
- Snapshot 1: Breakpoint after calling API to create ppt, at the very start of the code before any Spire related objects are created.
- Snapshot 2: Breakpoint before the end of the API and before disposing Spire objects. There are 2M objects and heap size is 112KB.
- Snapshot 3: Breakpoint after disposing Spire objects, before ending the API call. There are still 2M objects even after disposing and heap size is still at 100MB
- Snapshot 4: 1 minute after the end of the API calls. No other operations or API calls made. There are still 1M objects and heap size is 82MB. Upon further checking snapshot 4, most of the objects and the size in the heap is consumed by Hashtable and spire objects.
Code snippet looks like this:
- Code: Select all
using (var templatePresentation = new Spire.Presentation.Presentation())
{
var templatePresentationItem = new Spire.Presentation.Presentation();
templatePresentationItem.LoadFromFile(filePath);
// some code
templatePresentationItem.Dispose();
templatePresentation.LoadFromFile(filePath);
// some code
var presentation = new Spire.Presentation.Presentation();
//some code to copy properties and master from templatePresentation to presentation and generate presentation slides
presentation.Dispose();
}