Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Generator for Java (v3 and older)  /  OutOfMemoryError

DynamicPDF Generator for Java (v3 and older) Forum

 Jan 17 2006 5:14 PM

I am using Dynamic PDF Generator for Java and when i try to create a PDF document with many pages in it (5000 pages) with all TIF images and some JPEGs, i get this error:

Exception in thread "main" java.lang.OutOfMemoryError: ZIP002:OutOfMemoryError, MEM_ERROR in deflate_init2

Can you please help? I have given 1.5GB of heap memory for my java process to start.

I get error at this point:

where document is the Document object and rOut is my Output Stream.

 Jan 17 2006 5:24 PM
Posted by a ceTe Software moderator
Hello Ravi,

There are a couple possibilities for this:
1) The images you are using are large. If this is the case, you will run out of memory at the point when the total sizes of your images approach your heap size.
2) You are using certain types of TIFF images that cannot be handled in pass through mode. This greatly increases the amount of memory required to process the image. An example of this is an LZW compressed TIFF. LZW compressed TIFFs are uncompressed and manipulated before being embedded in the PDF. JPEGs are always handled in pass through mode.


ceTe Software Support Team
 Feb 06 2008 5:18 AM
I'm running into OutOfMemoryExceptions too.

I use pass-through image files, so there's no reason DynamicPDF should load them into ram before rendering the PDF. But I still run out of mem.

Do you have any plans to optimize memory consumption for large amounts of large images?

It's really a showstopper for me...

Kind regards,
Søren Skovsbøll
 Feb 06 2008 6:55 AM
Posted by a ceTe Software moderator
Hello Søren,

We have been able create PDF files of around 300MB in size successfully. What is the amount of physical memory (RAM) your machine on which the application is running have?

You can also refer to the PerformanceConsiderations topic on our help documentation which helps to increase the performance http://www.DynamicPDF.com/Support/Java_Help_Documentation_07_03/user-manual/PerformanceConsiderations.html, http://www.DynamicPDF.com/Support/Java_Help_Documentation_07_03/user-manual/Merger_PerformanceConsiderations.html.

A possible problem with the OutOfMemoryError could be that you are running out of Virtual Memory. Try increasing the Maximum heap size value and running the application again and see if you still get the error. Following is the command line syntax to increase the Virtual Memory size: java -Xms512m -Xmx512m <javaclassname>.

As a general rule, set minimum heap size (-Xms) equal to the maximum heap size (-Xmx) to minimize garbage collections.

ceTe Software Support Team.
 Feb 07 2008 5:43 AM
Thanks for the reply!

I'm using the .NET version of Generator (4.0.3) so there's no way to increase the heap size manually -- it's supposed to grow dynamically, I believe.

Image sizes are betweeen 5 and 500 Mb.

Kind regards,
 Feb 07 2008 8:34 AM
Posted by a ceTe Software moderator
Hello Søren,

The problem likely appears to be that the system is running out of physical memory when trying to create large PDF documents with several images of significant size. Make sure that the server has sufficient resources available to handle creation of large PDF documents.

Are you adding the same image to the document several times or are all the images unique? When using the same image in a document multiple times it is important to ensure that the image data is not included in the document multiple times.

Our product is designed to allow highly efficient reuse of images within a document or across several documents. The ImageData class is included for this purpose. When the same ImageData object is used multiple times in a PDF document, its data will only be included once in the resulting PDF document. Please refer to the Image Reuse topic in the help Documentation for further details on how to use ImageData object.

ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 5:31 PM.