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
-
It never returns , keeps running and consuming jvm heap
-
At certain point CPU usage becomes very high heap and parm gen gets full but i do not get any outOfMemoryException that is strange.
-
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.
-
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