[JAVA] Raise GC with jcmd

I was told when I was investigating the cause of a memory leak at work. Make a note so as not to forget it.

Get PID

First, find out the PID of the Java process you want to cause the GC. The story is then.

$ jps
#Java PID running on the same machine comes out with Walla Walla.

Cause GC

Specify the target PID and execute.

$ jcmd <PID> GC.run

I was monitoring with VisualVM, but the memory usage dropped sharply.

Recommended Posts

Raise GC with jcmd
Getting started with the JVM's GC mechanism