Hi,
I am using Aspose.PDF (21.9.0) to bundle several thousand single page PDF’s together (14,762 in this case)
During the process, it is necessary for me to compress this document.
This is the code I am using
var oo = new Aspose.Pdf.Optimization.OptimizationOptions();
oo.ImageCompressionOptions.ImageQuality = 20;
oo.ImageCompressionOptions.MaxResolution = 144;
oo.ImageCompressionOptions.ResizeImages = true;
oo.ImageCompressionOptions.CompressImages = true;
oo.ImageCompressionOptions.Version = Aspose.Pdf.Optimization.ImageCompressionVersion.Fast;
Parallel.ForEach(pages, page =>
{
using (Document page = new Document(page.FilePath))
{
page.OptimizeSize = true;
page.OptimizeResources(oo);
page.Save(page.CompressedPath);
}
});
The machine running this has 4 cores and 14GB of RAM
As you can see from the image below, the memory used for the compression of each page is never released.
image.png (32.4 KB)
Leaving this process running will eventually hit maximum memory usage and fall over.
I have tried joining all the files together and running a single compression operation, however, this also has the same issue.
What can you advise to avoid this problem?