Created
December 26, 2011 11:26
-
-
Save khotyn/1520947 to your computer and use it in GitHub Desktop.
Garbage collectors used in HotSpot JVM under different VM Options
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.lang.management.ManagementFactory; | |
import java.util.Set; | |
import javax.management.MBeanServer; | |
import javax.management.ObjectName; | |
/** | |
* Print the Collector used in the program. | |
* @author khotyn | |
*/ | |
public class GarbageCollectors { | |
public static void main(String[] args) throws InterruptedException, IOException { | |
MBeanServer server = ManagementFactory.getPlatformMBeanServer(); | |
Set<ObjectName> names = server.queryNames(null, null); | |
for (ObjectName name : names) { | |
if (name.toString().contains("GarbageCollector")) { | |
System.out.println(name); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo 'Client:' | |
java -client GarbageCollectors | |
echo 'Server:' | |
java -server GarbageCollectors | |
echo 'UseSerialGC:' | |
java -XX:+UseSerialGC GarbageCollectors | |
echo 'UseParallelGC:' | |
java -XX:+UseParallelGC GarbageCollectors | |
echo 'UseParNewGC:' | |
java -XX:+UseParNewGC GarbageCollectors | |
echo 'UseParalllelOldGC:' | |
java -XX:+UseParallelOldGC GarbageCollectors | |
echo 'UseConcMarkSweepGC:' | |
java -XX:+UseConcMarkSweepGC GarbageCollectors | |
echo 'UseG1GC:' | |
java -XX:+UseG1GC GarbageCollectors |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The result: