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

If you’re running JMX Console from a another machine, add these JVM arguments too:

-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.rmi.port=5000
-Djava.rmi.server.hostname=[place IP address here]

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.

Garbage collector log files can grow huge. You can use additional arguments like the following ones to rotate the log to a new log file when the current log file reaches a maximum size:

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

These arguments rotate the logs to up to 10 log files with a maximum size of 50M each.

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

« Introduction to Monitoring Liferay DXPIntroduction to Managing Liferay DXP with Liferay Connected Services »
Was this article helpful?
0 out of 1 found this helpful