We are trying replace our “QuickPDF” component with “Aspose.PDF”.
We found another issue when we call OptimizeResources() function of Document object. Below is the code that we are using.
private void OptimizeDocument(Document documentToOptimize)
Aspose.Pdf.Optimization.OptimizationOptions options = new Aspose.Pdf.Optimization.OptimizationOptions()
LinkDuplcateStreams = true,
RemoveUnusedObjects = true,
AllowReusePageContent = true,
RemoveUnusedStreams = true,
UnembedFonts = false,
options.ImageCompressionOptions.CompressImages = true; options.ImageCompressionOptions.ImageQuality = 100;// Should be 100 always else affects images appearance. options.ImageCompressionOptions.ResizeImages = true; documentToOptimize.OptimizeResources(options); }
Below is the screen shot of stack trace.
stack trace Screenshot (216).png (261.1 KB)
I believe our production application where we merge 1500 pdf pages, throws this exception when it crosses 1.2GB of memory usage, so in order to replicate this you just need to increase the number of files to merge(may be >5k) and call the “OptimizeDocument” function later.
Also, we have observed a sudden spike in memory from 300MB to 1.2GB when this function is called.
Update: We are getting another exception some of the times (refer below screenshot).
Screenshot (218).png (220.4 KB)
Please review and provide us a solution as soon as you can.