Post JSE 5 ergonomics is intended to automatically select the appropriate type of garbage collector for you (among other things).
I would like to know if there is an
(For Java <= 8)
This command print the GC type of a running JVM:
jmap -heap
For modern computer (multiple cpus, big memory), JVM will detect it as server machine, and use Parallel GC by default, unless you specify which gc to use via JVM flags explicitly.
e.g
jmap -heap 26806 | grep GC
Output:
Parallel GC with 8 thread(s)
(Thanks to @JakeRobb's comment.)
Since Java 9, there are 2 changes relevant to this question:
jhsdb to attach to a java process or launch a debugger.G1.Command format:
jhsdb jmap --heap --pid
e.g
jhsdb jmap --heap --pid 17573 | grep GC
Output:
Garbage-First (G1) GC with 8 thread(s)