-
-
Save jdanbrown/5246189 to your computer and use it in GitHub Desktop.
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.getKeyProperty("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
for flag in \ | |
-client \ | |
-server \ | |
-XX:+UseSerialGC \ | |
-XX:+UseParallelGC \ | |
-XX:+UseParNewGC \ | |
-XX:+UseParallelOldGC \ | |
-XX:+UseConcMarkSweepGC \ | |
-XX:+UseG1GC | |
do | |
echo $flag | |
java $flag GarbageCollectors | |
done |
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
-client | |
ConcurrentMarkSweep | |
ParNew | |
-server | |
PS MarkSweep | |
PS Scavenge | |
-XX:+UseSerialGC | |
Copy | |
MarkSweepCompact | |
-XX:+UseParallelGC | |
PS MarkSweep | |
PS Scavenge | |
-XX:+UseParNewGC | |
ParNew | |
MarkSweepCompact | |
-XX:+UseParallelOldGC | |
PS MarkSweep | |
PS Scavenge | |
-XX:+UseConcMarkSweepGC | |
ConcurrentMarkSweep | |
ParNew | |
-XX:+UseG1GC | |
G1 Old Generation | |
G1 Young Generation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment