Performance · AMP
Sizing Heap and Debugging JVM Memory Leaks in Liferay DXP
Isolate memory leaks by activating GC logging (-Xlog:gc*), collecting heap dumps using
jcmd during usage spikes, and analyzing class distributions in Eclipse Memory Analyzer (MAT) to
locate memory-retaining objects.
Activating Garbage Collection Logs
Add garbage collection parameters to your JVM configuration. Set path directories and flags. GC logs capture memory details, showing when collections execute and how much space is freed, exposing memory-retention bugs.
# Recommended JVM logging parameters
-Xlog:gc*,gc+age=trace,safepoint:file=/var/log/liferay/gc.log:time,uptime:filecount=5,filesize=50M
Collecting and Analyzing Heap Dumps
When OutOfMemory exceptions loom, collect heap dumps. Run tools like jmap or jcmd
against the Liferay process. Analyze the resulting hprof files in memory analyzers (like Eclipse MAT or VisualVM)
to isolate leaks.
Which Garbage Collection Settings Are Recommended for Liferay DXP?
Direct Answer: Configure GC algorithms like G1GC (using flags -XX:+UseG1GC -XX:MaxGCPauseMillis=200) to keep collection pauses short and prevent portal freezes.
Tune allocation thresholds. Set initial heap (-Xms) and maximum heap (-Xmx) to
identical values to prevent JVM resize delays, ensuring consistent server throughput.
Output GC logs regularly to files. Analyze pause trends and cycle durations to ensure JVM cleanup routines do not affect client response times.
Frequently asked questions
What JVM garbage collector is recommended for Liferay?
For heaps under 32GB, use G1GC. For heaps larger than 32GB, ZGC is recommended because it maintains low garbage collection pauses.
How much heap memory does Liferay DXP require?
Production portal instances typically require between 8GB and 16GB of heap, depending on concurrent traffic load.
Read the full article, with table of contents, comparison table, and author bio →