jdk7和jdk8的默认GC方式都一样:-XX:+UseParallelGC
可以用这个命令打印出来: java -XX:+PrintCommandLineFlags -version -------------------------------- 可以用jstack打印出线程堆栈
默认gc是这样:
"VM Thread" os_prio=2 tid=0x0000000017784000 nid=0x592c runnable
"GC task thread#0 (ParallelGC)" os_prio=0 tid=0x0000000001d0b000 nid=0x42b8 runnable
"GC task thread#1 (ParallelGC)" os_prio=0 tid=0x0000000001d0c800 nid=0x3e3c runnable
"GC task thread#2 (ParallelGC)" os_prio=0 tid=0x0000000001d0e000 nid=0x4f10 runnable
"GC task thread#3 (ParallelGC)" os_prio=0 tid=0x0000000001d0f000 nid=0x411c runnable
"VM Periodic Task Thread" os_prio=2 tid=0x00000000178cb800 nid=0x176c waiting on condition
JNI global references: 270
使用cms(-XX:+UseConcMarkSweepGC)是这样:
"VM Thread" os_prio=2 tid=0x00000000183fe000 nid=0x4ef8 runnable
"Gang worker#0 (Parallel GC Threads)" os_prio=2 tid=0x0000000002734000 nid=0x5bd0 runnable
"Gang worker#1 (Parallel GC Threads)" os_prio=2 tid=0x0000000002737800 nid=0x3904 runnable
"Gang worker#2 (Parallel GC Threads)" os_prio=2 tid=0x0000000002739800 nid=0x4d84 runnable
"Gang worker#3 (Parallel GC Threads)" os_prio=2 tid=0x000000000273b800 nid=0x43d4 runnable
"Concurrent Mark-Sweep GC Thread" os_prio=2 tid=0x0000000002782800 nid=0x231c runnable
"VM Periodic Task Thread" os_prio=2 tid=0x0000000018c4f000 nid=0x5144 waiting on condition
JNI global references: 270
很明显的,多了一个Concurrent Mark-Sweep GC Thread线程。
|