Issue with Presentation.Dispose() Method Blocking Other Threads

Hello,
The application I am working on is currently experiencing large amounts of server wide slowdowns due to the Dispose() calls in the Aspose.Slides .NET api.

To give some context, our webserver is receiving requests for a ppt file that we are converting to a pdf in order to display the file on the client in a pdf viewer. This is fine for the most part but some files are causing significant slowdowns that are felt by all clients rather than the one who requested for the file.

Is the Dispose() method blocking some sort of shared resource I am unaware of? Or is there some way to prevent this behavior?

Here is pseudo example code:

Using s as New MemoryStream
    Dim file as New Presentation(filePath)
    file.Save(s, Aspose.Slides.Export.SaveFormat.Pdf )
    file.Dispose() ' I would expect this call to not block other clients
    Return s.ToArray()
end using 

Note: We are currently using Aspose.Slides v 20.0.9 but I have also tried downloading the latest version and the problem persists.

@jon.hong

It seems that you are experiencing performance issues related to the Dispose() method in the Aspose.Slides .NET API, which is causing slowdowns across your server when processing certain PowerPoint files.

The Dispose() method is designed to release all resources used by the Presentation object. However, if the Dispose() method is blocking other threads, it could be due to contention for shared resources or locks that are being held during the disposal process. This can happen if multiple threads are trying to access or dispose of the same resources simultaneously.

Here are a few suggestions to mitigate this issue:

  1. Use Separate Instances: Ensure that each request to convert a PowerPoint file to PDF uses a separate instance of the Presentation class. This can help avoid contention between threads.

  2. Asynchronous Processing: Consider implementing asynchronous processing for your PDF conversion tasks. This can help improve the responsiveness of your application by allowing other requests to be processed while waiting for the Dispose() method to complete.

  3. Pooling: If you are frequently creating and disposing of Presentation objects, consider implementing an object pool. This allows you to reuse instances instead of creating new ones, which can reduce the overhead associated with resource allocation and disposal.

  4. Upgrade to Latest Version: Although you mentioned trying the latest version, ensure that you are using the most recent stable release of Aspose.Slides, as performance improvements and bug fixes are regularly included in updates.

  5. Profile Your Application: Use profiling tools to identify bottlenecks in your application. This can help you determine if the Dispose() method is indeed the source of the slowdown or if there are other factors at play.

Here is a modified version of your pseudo code that demonstrates the use of a separate instance for each request:

Using s As New MemoryStream()
    Dim file As New Presentation(filePath)
    file.Save(s, Aspose.Slides.Export.SaveFormat.Pdf)
    file.Dispose() ' This should not block other clients if instances are separate
    Return s.ToArray()
End Using

By following these suggestions, you should be able to reduce the impact of the Dispose() method on your server’s performance. If the issue persists, consider reaching out to Aspose support for further assistance.

Sources:
[1]: Dispose | Aspose.Slides for .NET API Reference

@jon.hong,

Unfortunately, I don’t have any information about this yet. We are sorry that you encountered this problem. We need more details to investigate the case. Could you please share a sample project along with the presentation files so we can reproduce the issue on our end?

I don’t think I can provide a sample project today but the problem is happening with very basic examples. We are using a “using” block in our code but to isolate the problem I broke timed different parts of our code so it would look like this. For context, we had some cases where we were just trying to receive the author of the file so we would simply open the file and retrieve the author, then dispose.

 Dim file As New Aspose.Slides.Presentation(AbsPath)
 Dim createdBy As String = file.DocumentProperties.Author
 file.Dispose()

As soon as the Dispose() part ran, we noticed other browser clients all had around a 2 second pause. Even though they were doing completely unrelated actions. I don’t necessarily mind if the dispose is a little slow, but the real issue is that it is affecting others.

Here is the ppt file that was causing the slowdowns.
60359G.zip (670.3 KB)

And again just for reference. we are currently only aspose.slides 20.9.0

@jon.hong,
Thank you for the sample presentation and additional information. Unfortunately, I was unable to reproduce the issue you described. We need a sample project to investigate the case further.

I’ve actually isolated the issue to the Dispose() method activating a full garbage collection which is why the other clients are also experiencing the delay. Is there any ability within the constrcution of the Presentation object to not create objects that enter the loh?

I’ve tried using the BlobManagementOptions in the load options of the constructor but that doesn’t seem to make a difference.

@jon.hong,

Unfortunately, I am not aware of such an ability. We would greatly appreciate it if you could share a sample project or scenario to reproduce the issue. Then, we would do our best to help you.