查看JVM默认垃圾收集器

一、查看JVM默认垃圾收集器

java -XX:+PrintCommandLineFlags -version
[root@jeespring ~]# java -XX:+PrintCommandLineFlags -version
-XX:InitialHeapSize=132500800 -XX:MaxHeapSize=2120012800 -XX:+PrintCommandLineFlags 
-XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:-UseLargePagesIndividualAllocation -XX:+UseParallelGC
java version "1.8.0_211"
Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)

垃圾收集相关的常用参数

参数描述
UseSerialGC虚拟机运行再Client模式下的默认值,打开此开关后,使用Serial+Serial Old的收集器组合进行内存回收
UseParNewGC打开此开关后,使用ParNew+Serial Old的收集器组合进行内存回收
UseConcMarkSweepGC打开此开关后,使用ParNew+CMS+Serial Old的收集器组合进行内存
UseParallelGC虚拟机运行在Server模式下的默认值,打开此开关后,使用Parallel Scavenge+Serial Old(PS MarkSweep)的收集器组合进行内存回收
UseParallelOldGC打开此开关后,使用ParallelSeavenge+ParallelOld的收集器组合进行内存回收
SurvivorRatio新生代中Eden区域与Survivor区域的容量比值,默认为8,代表Eden:Survivor=8:1
PretenureSizeThreshold直接晋升到老年代的对象大小,设置这个参数后,大于这个參数的对象将直接在老年代分配
MaxTenuringThreshold晋升到老年代的对象年龄。每个对象在坚持过一次MinorGC之后,年龄就增加1,当超过这个参数值时就进人老年代

二、 命令查看java垃圾收集器

jmap -heap pid

输出结果中,可以查看当前线程使用垃圾收集器

using parallel threads in the new generation.

using thread-local object allocation.

Concurrent Mark-Sweep GC

输出结果

[root@jeespring ~]# jmap -heap 30620
Attaching to process ID 30620, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.261-b12

using thread-local object allocation.
Mark Sweep Compact GC

Heap Configuration:
   MinHeapFreeRatio         = 40
   MaxHeapFreeRatio         = 70
   MaxHeapSize              = 1048576000 (1000.0MB)
   NewSize                  = 10485760 (10.0MB)
   MaxNewSize               = 349503488 (333.3125MB)
   OldSize                  = 20971520 (20.0MB)
   NewRatio                 = 2
   SurvivorRatio            = 8
   MetaspaceSize            = 21807104 (20.796875MB)
   CompressedClassSpaceSize = 1073741824 (1024.0MB)
   MaxMetaspaceSize         = 17592186044415 MB
   G1HeapRegionSize         = 0 (0.0MB)

Heap Usage:
New Generation (Eden + 1 Survivor Space):
   capacity = 9437184 (9.0MB)
   used     = 3119576 (2.9750595092773438MB)
   free     = 6317608 (6.024940490722656MB)
   33.05621676974826% used
Eden Space:
   capacity = 8388608 (8.0MB)
   used     = 2071008 (1.975067138671875MB)
   free     = 6317600 (6.024932861328125MB)
   24.688339233398438% used
From Space:
   capacity = 1048576 (1.0MB)
   used     = 1048568 (0.9999923706054688MB)
   free     = 8 (7.62939453125E-6MB)
   99.99923706054688% used
To Space:
   capacity = 1048576 (1.0MB)
   used     = 0 (0.0MB)
   free     = 1048576 (1.0MB)
   0.0% used
tenured generation:
   capacity = 20971520 (20.0MB)
   used     = 4970272 (4.740020751953125MB)
   free     = 16001248 (15.259979248046875MB)
   23.700103759765625% used

4606 interned Strings occupying 362992 bytes.

三、各个版本JDK默认的垃圾回收器

jdk1.7 默认垃圾收集器Parallel Scavenge(新生代)+Parallel Old(老年代)

jdk1.8 默认垃圾收集器Parallel Scavenge(新生代)+Parallel Old(老年代)

jdk1.9 默认垃圾收集器G1

 

    原文作者:前尘忆梦Memory
    原文地址: https://blog.csdn.net/zhangchaoyang/article/details/107942670
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞