Skip to content

Instantly share code, notes, and snippets.

@upadhyayap
Last active September 15, 2015 11:00
Show Gist options
  • Save upadhyayap/a351339ba8e8214d5d8c to your computer and use it in GitHub Desktop.
Save upadhyayap/a351339ba8e8214d5d8c to your computer and use it in GitHub Desktop.
Issue while building pdf using PdfDocumentBuilder of Groovy Document Builder

I am using Groovy document builder for dynamically generating pdf files in development environment now and have plans to put it in production. While in development i observed some random behaviour by the API and i managed to create a dummy code to demostrate it.

when i run the code

  1. It never returns , keeps running and consuming jvm heap

  2. At certain point CPU usage becomes very high heap and parm gen gets full but i do not get any outOfMemoryException that is strange.

  3. When i took the heap dump and analyzed it then found that there are lot of (in one particular case around 10000) COSDictionary objects are getting created and that does not gets collected by the garbage collector.

  4. I drilled down more and went inside the API class PdfDocumentBuilder and observed that in onTableComplete method there is while loop and that gets transformed in an infinite loop when i supply the DSL in a manner decribed in the code.

Demo code can be found on https://github.com/upadhyayap/GdbDemo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment