We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

document.optimizeresources(optVals) throwing out of memory exception

I am using the below code to optimize (shrink) existing large PDF files in VS2012 using vb.net:

Dim aspDoc As New Aspose.Pdf.Document(strFN)
Dim optVals As New Aspose.Pdf.Document.OptimizationOptions

optVals.CompressImages = True
optVals.ImageQuality = 22
optVals.RemoveUnusedObjects = True
optVals.RemoveUnusedStreams = True
optVals.LinkDuplcateStreams = True
aspDoc.OptimizeSize = True
Try
aspDoc.OptimizeResources(optVals)
Catch ex As Exception
MsgBox(“Error optimizing resources!”, MsgBoxStyle.Exclamation, “”)
End Try

aspDoc.Save(strFN)

aspDoc.Dispose()
GC.Collect()
aspDoc = Nothing
GC.Collect()

It works just fine on the 1st PDF file, shrinks down from 50+ MB to 5 MB but throws an OUT OF MEMORY exception on any subsequent attempts on other PDF files of the same magnitude during the same run-time session. So only the 1st large PDF file gets optimized without error. See below error:



When I check performance in task manager it shows 5.38 GIG used out of 8 GIG total usuable memory. Why?

Hi Michael,


Thanks for your inquiry. Please share your source PDF document, we will investigate it at our end and will provide you more information accordingly.

Moreover your source source PDF document is quite large, so please share it via some free file sharing service e.g. dropbox, skydrive etc, for investigation.

We are sorry for the inconvenience caused.

Best Regards,

Please use ftp to download the large PDF file as follows;

Host: ftp.linkproducts.ca

Username: asposesupport
Password: aspose001

Let me know if any issues.

Also
look forward to a solution as we purchased the license for this very
purpose and only this purpose (for now). If we cannot use it we spent
the $$$ for nothing. I did test it before purchasing but did not expect
such a situation.

Thanks
Michael Margulies

Hi Michael,


Thanks for sharing your source document. We are looking into it and will guide you accordingly.

Best Regards,

Hi Michael,


Thanks for sharing the resource file.

I have tested the scenario using Aspose.Pdf for .NET 9.7.0 in Visual Studio 2010 running over Windows 7 (x64) and I am unable to notice any problem. For your reference, I have also attached the resultant PDF generated over my end. Can you please try using the latest release and in case the problem still persists, please share some details regarding your working environment i.e. Operating System, OS Architecture (X64 / X86), .NET Framework version etc.

Hmmmm, I since rebooted my computer and tried again and it is working fine now.

Thanks for your help anyways.

:slight_smile:

Hi


Thanks for your feedback. It is good to know that your issue has been fixed.

Please keep using our API and feel free to ask any question or concern. We will be more than happy to extend our support.

Best Regards,

Hi Michael,


Adding more to Tilal’s comments, it appears that there were some other processes running over your system which were consuming system resources. Once you have restarted the machine, the resource are free and Aspose.Pdf for .NET is getting ample resources to performed required functionality.