Search code examples
javagarbage-collectionjava-6

Java Garbage Collection Strategy


I'm looking for a technique to find out the Garbage Collection (GC) strategy (collector) the Java VM is using at a given point of time. (Later on, I'd like it to correctly reflect the strategy that I choose, say XX:+UseConcMarkSweepGC.)

verbose:gc (in its basic form) does not help as it just shows me what all it did with each generation. Is there any other flag I can set to make it spit out the GC strategy being utilized?

JDK version is 1.6_21


Solution

  • Mmmm.. you can certainly find out what strategy is being used by a certain JVM with jconsole (VM Summary) page. Not sure about influencing it, or changing it.

    EDIT: To assist you with programmatically checking and changing JVM flags of a running VM you can use the jinfo.exe utility in the JDK. For example to check if the ParallelGC flag is set you can run: jinfo.exe -flag UseParallelGC <PID>.