Monitoring Garbage Collection and JVM

Although the tuning parameters give you a good start to tuning your JVM, you must monitor GC performance to ensure you have the best settings to meet your needs. There are several tools to help you monitor Oracle JVM performance including.

Visual VM

This tool provides a centralized console for viewing Oracle JVM performance information, including garbage collector activities.

Visual VM shows the garbage collector in real-time.

JMX Console

This tool helps display various statistics like Liferay DXP’s distributed cache performance, the performance of application server threads, JDBC connection pool usage, and more.

To enable JMX connections, add these JVM arguments:

If you’re running JMX Console from a another machine, add these JVM arguments too:
-Djava.rmi.server.hostname=[place IP address here]

Visual VM lets you monitor using Java Management Extensions.

Garbage Collector Verbose Logging

Add the following configuration to your JVM arguments to activate verbose logging for the JVM garbage collector.

-verbose:gc -Xloggc:/tmp/liferaygc1.log -XX:+PrintGCDetails 
-XX:+PrintGCCause -XX:+PrintGCApplicationConcurrentTime 

You will need these logs to tune the JVM properly.

Note: To ensure you do have sufficient debugging information if your JVM encounters out of memory scenarios, you should consider adding this:

-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp/dumps

Garbage collector log files can grow huge. Arguments like the ones below rotate the logging to a new file when the log file reaches a maximum size:

-XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 

These arguments rotate the logs to as many as 10 log files, each with a 50M size limit.

« Introduction to Monitoring Liferay DXPAdvanced Monitoring: APM Tools - Dynatrace »