我正在尝试使用 jcmd VM.set_flag 选项。但是遇到了一个错误,说“只能设置'可写'标志”。什么是可写标志?
获取我的 pid:
XXX@XXX-Air:~/javacode$ jcmd -l
6294 Test
6295 jdk.jcmd/sun.tools.jcmd.JCmd -l
尝试更改 vm 标志:
XXX@XXX-Air:~/javacode$ jcmd 6294 VM.set_flag ConcGCThreads 4
6294:
only 'writeable' flags can be set
XXX@XXX-Air:~/javacode$ jcmd 6294 VM.set_flag MaxNewSize 1G
6294:
only 'writeable' flags can be set
编辑:它适用于可管理的标志,以下是成功的命令。
XXXX@XXX-Air:~/javacode$ jcmd 11441 VM.flags -all | grep MinHeapFreeRatio
uintx MinHeapFreeRatio = 40 {manageable} {default}
XXXX@XXX-Air:~/javacode$ jcmd 11441 VM.set_flag MinHeapFreeRatio 45
11441:
Command executed successfully
XXXX@XXX-Air:~/javacode$ jcmd 11441 VM.flags -all | grep MinHeapFreeRatio
uintx MinHeapFreeRatio = 45