如何检查JVM正在使用哪个GC?

时间:2016-10-28 17:44:16

标签: garbage-collection jvm

我有运行服务器(oracle / sun)的JVM,如何检查它在运行时使用的GC?例如,如果它使用UseG1GC UseConcMarkSweepGC。 (jdk是1.7_79)

我知道我可以使用jinfo <pid>从输出中检查VM Flags。但是如果在没有这些参数的情况下启动JVM会怎样。

我在jvisualvm中找不到此信息。

1 个答案:

答案 0 :(得分:3)

使用JMap。

jMap - 使用-heap选项启动此工具,并找到专用于垃圾收集器类型的字符串。喜欢

$ jmap -heap 30166
Attaching to process ID 30166, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 24.80-b11

using parallel threads in the new generation.
using thread-local object allocation.
Concurrent Mark-Sweep GC

Heap Configuration:
   MinHeapFreeRatio = 40
   MaxHeapFreeRatio = 70
   MaxHeapSize      = 4294967296 (4096.0MB)
   NewSize          = 1431633920 (1365.3125MB)
   MaxNewSize       = 1431633920 (1365.3125MB)
   OldSize          = 2863267840 (2730.625MB)
   NewRatio         = 2
   SurvivorRatio    = 8
   PermSize         = 21757952 (20.75MB)
   MaxPermSize      = 85983232 (82.0MB)
   G1HeapRegionSize = 0 (0.0MB)

Heap Usage:
New Generation (Eden + 1 Survivor Space):
   capacity = 1288503296 (1228.8125MB)
   used     = 339354840 (323.63399505615234MB)
   free     = 949148456 (905.1785049438477MB)
   26.337134026236903% used
Eden Space:
   capacity = 1145372672 (1092.3125MB)
   used     = 313863536 (299.32359313964844MB)
   free     = 831509136 (792.9889068603516MB)
   27.402743550005006% used
From Space:
   capacity = 143130624 (136.5MB)
   used     = 25491304 (24.310401916503906MB)
   free     = 117639320 (112.1895980834961MB)
   17.809818253849016% used
To Space:
   capacity = 143130624 (136.5MB)
   used     = 0 (0.0MB)
   free     = 143130624 (136.5MB)
   0.0% used
concurrent mark-sweep generation:
   capacity = 2863333376 (2730.6875MB)
   used     = 0 (0.0MB)
   free     = 2863333376 (2730.6875MB)
   0.0% used
Perm Generation:
   capacity = 23920640 (22.8125MB)
   used     = 23801432 (22.698814392089844MB)
   free     = 119208 (0.11368560791015625MB)
   99.5016521297089% used

10243 interned Strings occupying 814216 bytes.