Java Memory Profiler Reference
If your Java Engine is struggling to make a report here is some useful information.
Profiling a memory usage is an essential step to make sure that there are no memory leaks in an application. Here are some useful tools that allow a profiler:
- VisualVM - a profiler and its Visual GC plugin
- IntelliJ has a plugin for VisualVM which easily allows to start a profiler from within the IDE
Running an application under profiler allows to monitor its memory usage, how a GC performs, the heap memory grooving, etc. Taking a heap dump allows you to analyze the state of the heap. The thinks like what objects are there, their sizes and counts, etc. If the heap size is grooving over time without being released, it’s an indicator of a possible memory leak.
When running the engine make sure to close the template, report, and datasource objects as soon as they are no longer needed.
For a massive amount of data when generating big reports (thousands of pages) you may encounter an out of memory problem. It doesn’t mean that there is a memory leak somewhere, but rather that JVM has not enough memory to complete its job. A big report creates lots of long-living objects in memory (millions of objects). Many objects are needed to stay during the whole report generation process: data processing, layout, output writing.
Tuning the JVM allows to improve performance of the engine. One helpful option when generating a big report:
-Xms8g -Xmx8g -XX:+UseCompressedOops -XX:+UseG1GC -XX:MaxGCPauseMillis=500
If an application fails with the OutOfMemoryError exception, try restarting the JVM