How to manually force a full garbage collection in Confluence
Purpose
While we do not recommend manually tuning Garbage Collection (GC) properties, manually forcing a full GC when testing memory adjustments in a development environment may become necessary.
Solution
- First, you will need to run Confluence through a JDK from Java version 8 or higher. In Java 8+ JDK, the jcmd utility is accessed and used to initiate the full garbage collection. (You can find this command under your $JDK_HOME/bin/)
Run a jcmd command to reveal all processes and their PIDS currently running on Confluence
jcmd
Review the output of processes and notate the PID located for a process running under Tomcat Catalina. In the following example the PID is 12345
12345 org.apache.catalina.startup.Bootstrap start
Using the PID from step 3., run the following command (where xxxx is PID) to trigger the full GC:
jcmd xxxx GC.run
The process should run and generate the following execution message:
Command executed successfully