Page 1 of 1

OutOfMemory

PostPosted: Wed Dec 21, 2016 7:16 pm
by Olivier
Hi,

I have a problem. I use docx4j in a lot of projects and there is the same problem in all of them: when i want to generate ToC I have an OutOfMemory error. I have the heap dump and the main problem come from this class : org.apache.fop.fo.XMLWhiteSpaceHandler. Can you tell me why this class is used? and may be why there is a problem with it?

Thanks a lot

Best regards

Re: OutOfMemory

PostPosted: Wed Dec 21, 2016 7:32 pm
by jason
You are using XSL FO for the page layout model, used to determine page numbers.

I haven't noticed any issue caused by fo.XMLWhiteSpaceHandler in the past.

You could allocate more memory to the VM. How much are you allocating? How big are your documents?

Or, if you are using v3.3.x, you could remove the docx4j-export-fo jar from your classpath, so that the commercial PDF Converter is used instead to calculate the page numbers. This is faster, more resource efficient and more accurate, but is native code specific to whatever OS you are running.

Re: OutOfMemory

PostPosted: Wed Dec 21, 2016 9:57 pm
by Olivier
Ok thanks. generating ToC is more faster without docx4j-export-fo. but there is another problem. The object MainDocumentPart is never destroy by the garbage collector. The memory of tomcat server increases steadily until the crash.

Re: OutOfMemory

PostPosted: Thu Dec 22, 2016 12:00 am
by Olivier
No sorry ToC generating doesn't work without docx4j-export-fo :cry:

Re: OutOfMemory

PostPosted: Thu Dec 22, 2016 7:08 am
by jason
It should work without export-fo. I just had to restart converter-eval server. You can/should install your own instance of the PDF Converter. Download it from converter-eval.plutext.com

Memory should not leak; please check your code/env. https://github.com/plutext/docx4j/blob/ ... .java#L230 is an example of cleaning up after export-fo.

Re: OutOfMemory

PostPosted: Fri Jan 06, 2017 1:55 am
by Olivier
Hi Jason

we have test it but it leave an exception :

Code: Select all
ec.ep.dit.actes.documents.DocumentsException: org.docx4j.toc.TocException: Error in toc web service at http://127.0.0.1:80/v1/00000000-0000-0000-0000-000000000000/convert
HTTP response: 404 Not Found


Can you explain how create a instance of the PDF Converter. The package PDF Converter is in the 3.3.2 release

Re: OutOfMemory

PostPosted: Fri Jan 06, 2017 10:28 am
by jason
Download it from http://converter-eval.plutext.com/ and install it following the instructions there.

The converter itself is OS-specific native code, not Java. docx4j invokes it via HTTP