Microsoft.Office.Interop.PowerPoint.Presentation.Close slows down over time
I have a C# application that gets called as a command line task (e.g. "application.exe param1 param2"). The application uses the Microsoft.Office.Interop.PowerPoint package to merge several individual PowerPoint presentations together.
I've noticed that over time the process takes longer and longer to complete. I have wrapped all calls to functions in the Microsoft.Office.Interop.PowerPoint package in a timer and plotted the results over time to find that the Microsoft.Office.Interop.PowerPoint.Presentation.Close function has a very clear upward trend line.
Are there any reasons why this function would take longer the more times it is called or the more times PowerPoint is interacted with?
The only way to speed this up so far has been to delete the user profile of the user it runs under. I have tried deleting a variety of temp files but nothing that I've deleted so far as helped. I have also looked through the registry for any hints but have not come across any.
Any help would be very much appreciated; this one has me stumped.
Environment details:
- Microsoft.Office.Interop.PowerPoint Package
- Version: 5.0.4420.1017
- Target Framework: net48
- PowerPoint 2016
- Version: 2311
- OS
- Windows Server 2019 (this has happened on Windows Server 2012 as well)