Monitoring Garbage Collection and the JVM

Although the tuning parameters give you a good start to JVM tuning, 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.

VisualVM

VisualVM provides a centralized console for viewing Oracle JVM performance information and its Visual GC plugin shows garbage collector activities.

Figure 1: VisualVMs Visual GC plugin shows the garbage collector in real-time.

Figure 1: VisualVM's Visual GC plugin shows the garbage collector in real-time.

JMX Console

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

To enable JMX connections, add these JVM arguments:

-Dcom.sun.management.jmxremote=true
-Dcom.sun.management.jmxremote.port=5000
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false

Figure 2: VisualVM monitors the JVM using Java Management Extensions.

Figure 2: VisualVM monitors the JVM using Java Management Extensions.

Garbage Collector Verbose Logging

Add these JVM arguments to activate verbose logging for the JVM garbage collector.

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

Examining these logs helps you tune the JVM properly.

Note: Adding these JVM arguments generates a heap dump if an OutOfMemoryError occurs. The dump is written to the heap dump path specified. Specify the path to use:

-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/heap/dump/path/

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

-XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 
-XX:GCLogFileSize=50M

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

Now you can monitor garbage collection in the JVM and tune it for top performance.

« Introduction to Monitoring Liferay DXPAdvanced Monitoring: APM Tools; Dynatrace »
Was this article helpful?
0 out of 1 found this helpful