OutOfMemoryError

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Generator for Java (v4)  /  OutOfMemoryError

DynamicPDF Generator for Java (v4) Forum

 Aug 17 2010 10:37 AM
I am getting the error below after generating multiple PDFs one after another.  I did some looking around and found that whatever is happening in java.util.zip.Deflater.init(Native Method) doesn't force the garbage collector to run if it needs more memory.  So, if I place a System.gc() after the Document.draw() call, it seems I can avoid this error.  However, this is not something I would like to do.

I also did some testing with java.util.zip.Deflater and it looks like a call to Deflater.end() will free up native memory used by the deflater and avoid this error.  Maybe this is something that can be fixed?  Is there anything else I can do to avoid this problem?

java.lang.OutOfMemoryError
        at java.util.zip.Deflater.init(Native Method)
        at java.util.zip.Deflater.<init>(Deflater.java:123)
        at java.util.zip.Deflater.<init>(Deflater.java:132)
        at com.cete.dynamicpdf.io.ContentBuffer.a(Unknown Source)
        at com.cete.dynamicpdf.io.OperatorWriter.j(Unknown Source)
        at com.cete.dynamicpdf.Page.drawEntries(Unknown Source)
        at com.cete.dynamicpdf.Page.draw(Unknown Source)
        at com.cete.dynamicpdf.io.SinglePassDocumentWriter.f(Unknown Source)
        at com.cete.dynamicpdf.io.SinglePassDocumentWriter.draw(Unknown Source)
        at com.cete.dynamicpdf.Document.draw(Unknown Source)
 Aug 18 2010 1:19 PM
Posted by a ceTe Software moderator
Hello,

A possible problem with the OutOfMemoryError could be that you are running out of Virtual Memory. Try increasing the Maximum heap size value and run 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.

If you still continue seeing this error please provide us with the follow information:

1. The code to regenerate the issue. Send it to our Support team.
2. What OS they are using?

Thanks,
ceTe Software Support Team
 Aug 19 2010 9:47 AM
Posted by a ceTe Software moderator
Hello,

After looking into this further, it looks like "out of memory" exception is not coming from heap area but coming from native(non java) memory area. So can you try to enable incremental gc using -Xincgc instead -Xms and -Xmx and another option to try is, after call to the draw method call System.runFinalization() method.

If both solutions do not work, please send us the code that you are uing so that we can try to recreate it on our end.

Thanks,
ceTe Software Support Team

All times are US Eastern Standard time. The time now is 9:24 PM.