Loading

How to enable Garbage Collection logs for performance tuning

Publiseringsdato: Aug 26, 2025
Oppgave

Collect GC information for an on-premise Mule Runtime instance.

Trinn

Option 1: Through the JDK installed in your environment (Mule Runtime restart not required).

For this purpose, it is necessary to have JDK installed (not just JRE) in your environment. Run the following command:

jstat -gccause -h 1000 -t <pid> 10s > gc.log

This will dump the output to the gc.log file. In the above command, <pid> stands for Java Process ID of the Mule Runtime instance. For more information about "jstat" command, please check the official documentation here

With the above command, it is not necessary to restart the Mule Runtime instance. 

Note: In the generated logs the timestamp is the number of milliseconds since the JVM has started. Also, the number of GC and the time that it take are cumulative. This is very important to correctly read these logs and analyze the results.

 

Option 2: Without JDK installed in your environment (only JRE installed and this will require Mule Runtime restart).

Firstly, identify the GC algorithm used by referring to the article: How to Check What Garbage Collection Algorithm is Used by a Running JVM

  • If the GC algorithm is "ParallelGC"

The wrapper.conf file under the <MULE HOME>/conf folder has listed the following lines, which are commented out. If there is no JDK installed, the alternative is to uncomment the lines below and restart Mule Runtime. The <n> placeholders should be replaced with a sequence of numbers.

wrapper.java.additional.<n>=-XX:+PrintGCApplicationStoppedTime 
wrapper.java.additional.<n>=-XX:+PrintGCDetails 
wrapper.java.additional.<n>=-XX:+PrintGCDateStamps 
wrapper.java.additional.<n>=-Xloggc:%MULE_HOME%/logs/gc.log 
wrapper.java.additional.<n>=-XX:+UseGCLogFileRotation 
wrapper.java.additional.<n>=-XX:NumberOfGCLogFiles=5 
wrapper.java.additional.<n>=-XX:GCLogFileSize=10M


Note: To avoid the GC logs being overwritten at startup, it is possible to parameterize the GC log file name. There are two options available for use;

%p - the process id for the JVM
%t - the current timestamp

For example, to use the process id and timestamp in the filename, use a "loggc" entry similar to below;

wrapper.java.additional.<n>=-Xloggc:%MULE_HOME%/logs/gc-%p-%t.log
  • If the GC algorithm is "G1GC"

The parameters mentioned above will fail the deployment when using G1GC algorithm so they must be left commented out and instead use the parameter below to the wrapper.conf file and perform Mule Runtime restart.

The <n> placeholders should be replaced with a sequence of numbers.

wrapper.java.additional.<n>=-Xlog:gc*:file=%MULE_HOME%/logs/gc.log:tags,time,uptime,level:filecount=10,filesize=2M

 

Knowledge-artikkelnummer

001115026

 
Laster
Salesforce Help | Article