Aspose PDF - OutOfMemory exception when the document content is too large

Hello,

We generate PDF using multiple elements, e.g. Tables, Images, Charts, hyperlinks on each page, latex fragments and latex pdf files merged into main PDF.

As the size of the pdf increases, the application throws outOfMemory exception

After the document is generated, the toc and bookmarks are created in the PDF.
For bookmark creation, I have to navigate the “ChapterNumber” in the document and get its page number and position.

If the documet is too large and we find some text in the file, Page.Accept(textFragment) gives exception of outOfMemory exception.

Because of project data, I cannot share with you the pdf files which gives exception

@PriyankaShelke

Thanks for contacting support.

In order to deal with large PDF documents, it is recommended to use x64 mode of debugging, so that your program could use all available memory installed. However, such issues may also be related with specific type of documents which have specific complexity and structure of content. In order to investigate the issue and resolve it, we need to observe similar issue in our environment and for the purpose we need sample PDF document.

You may please share your PDF document in a private message, and shared files will only be accessible to Aspose Staff. We assure you that we do not disclose files with anyone and they are only used for investigation purposes. We erase them soon after investigation is completed.

Program.zip (911 Bytes)

Please find the function which gives out of memory exception.

@PriyankaShelke

Thanks for sharing the sample code snippet.

However, as requested earlier, we need sample PDF document, with which you are facing OutOfMemoryException. This would really help us, testing the scenario and address it accordingly. Also, would you please share you environment details i.e. OS Version and Name, Installed Memory Size, API Version, and Application Type.

The system environment is -

  1. OS Name - Windows 7
  2. OS version - Windows 7 x 64 SP1
  3. Installed memory size - 8 GB
  4. API Version - 17.2
  5. Application Type- WPF windows application
  • On 29July 2018- I have shared Program.zip. It contains a function CreateDocument() which you can add in your sample project and run

  • The CreateDocument() provides similar layout as we have in our project requirement. So, I have shared with you the dummy code which could replicate the scenario.

  • The application will throw “out of memory” exception. As the application is throwing exception, PDF is not generated and hence cant be shared.

@PriyankaShelke

Thanks for sharing requested information.

We have tested the scenario using latest version of the API i.e. Aspose.PDF for .NET 18.6 and were unable to notice any issue. Your code did not throw OutOfMemoryException Exception, with latest version. For your kind reference, we have also attached generated PDF. Chart.pdf (3.3 MB) We have used one of our sample images in PDF document for testing purposes.

Please note that it is always recommended to use latest version of the API, as it contains more fixes and performance improvements. We request you to please try your scenario using latest version of the API and in case you still face any issue, please let us know. We will further proceed to help you.

  1. I am using 18.11 version dll but still the problem persists.
  2. I have gone through lots of Aspose forum threads. General observation is : Many people have reported OutOfMemory Exception. I want to know if there is any specific code which should be handled at developer side so as to avoid such exception ?
  3. I have reported Ticket #172537 ,in which excption was OutOfMemory Exception. It is resolved now. Can you provide me the solution what caused the exception? So, that I will fix the issue at my end in Aspose PDF usage code. There are other areas in our code(which we cannot share with you) which leads to OutOfMemory Exception. so, if you provide the solution I can handle it at my end

@PriyankaShelke

Thanks for contacting support.

Please note that we cannot generally specify the reason of OutOfMemory Exception as it may be environment or scenario specific in different cases. Also, sometimes issues are resolved by the changes made in internal components of the API. Nevertheless, we request you to please share complete sample code snippet along with input files (if any) so that we can test the scenario in our environment and address it accordingly.