Java jcmd 动态修改 JVM 启动参数

Java jcmd 大约 1547 字

说明

文中的12345为进程的pid

列出所有标志

Linux

jcmd 12345 VM.flags -all | grep manageable

Windows

jcmd 12345 VM.flags -all | findstr manageable

Java11为例

PS C:\WINDOWS\system32> jcmd 1000 VM.flags -all | findstr manageable
     intx CMSAbortablePrecleanWaitMillis           = 100                                    {manageable} {default}
     intx CMSTriggerInterval                       = -1                                     {manageable} {default}
     intx CMSWaitDuration                          = 2000                                   {manageable} {default}
     bool HeapDumpAfterFullGC                      = false                                  {manageable} {default}
     bool HeapDumpBeforeFullGC                     = false                                  {manageable} {default}
     bool HeapDumpOnOutOfMemoryError               = false                                  {manageable} {default}
    ccstr HeapDumpPath                             =                                        {manageable} {default}
    uintx MaxHeapFreeRatio                         = 70                                     {manageable} {default}
    uintx MinHeapFreeRatio                         = 40                                     {manageable} {default}
     bool PrintClassHistogram                      = false                                  {manageable} {default}
     bool PrintConcurrentLocks                     = false                                  {manageable} {default}

改变参数

FullGCDump出堆内存。

jcmd 12345 VM.set_flag HeapDumpAfterFullGC true
阅读 66 · 发布于 2021-09-18

————        END        ————

扫描下方二维码关注公众号和小程序↓↓↓

扫描二维码关注我
昵称:
随便看看 换一批