2017-10-17 51 views
5

我試圖用jcmd VM.set_flag選項進行試驗。但遇到一個錯誤,說只有'可寫'標誌可以設置「。什麼是可寫標誌?jcmd VM.set_flag,哪些標誌是可寫的?

讓我的PID:

[email protected]:~/javacode$ jcmd -l 
6294 Test 
6295 jdk.jcmd/sun.tools.jcmd.JCmd -l 

試圖改變VM標誌:

[email protected]:~/javacode$ jcmd 6294 VM.set_flag ConcGCThreads 4 
6294: 
only 'writeable' flags can be set 
[email protected]:~/javacode$ jcmd 6294 VM.set_flag MaxNewSize 1G 
6294: 
only 'writeable' flags can be set 

編輯:工作了管理的標誌,下面是成功的命令。

[email protected]:~/javacode$ jcmd 11441 VM.flags -all | grep MinHeapFreeRatio 
    uintx MinHeapFreeRatio       = 40         {manageable} {default} 
[email protected]:~/javacode$ jcmd 11441 VM.set_flag MinHeapFreeRatio 45 
11441: 
Command executed successfully 
[email protected]:~/javacode$ jcmd 11441 VM.flags -all | grep MinHeapFreeRatio 
    uintx MinHeapFreeRatio       = 45  
+2

VM.set_flag是在Java 9可用經由http://openjdk.java.net/jeps/228,它是jdk9特定選項。不是嗎? – Vipin

回答

3

可寫入標記標記爲{manageable}

您可以用jcmd 12345 VM.flags -all列出所有標誌。然後,您可以grep爲易於管理的(該是我的Oracle jdk8 VM):

$ jcmd 12345 VM.flags -all | grep manageable 
    intx CMSAbortablePrecleanWaitMillis   = 100         {manageable} 
    intx CMSTriggerInterval      = -1         {manageable} 
    intx CMSWaitDuration       = 2000        {manageable} 
    bool HeapDumpAfterFullGC      = false        {manageable} 
    bool HeapDumpBeforeFullGC      = false        {manageable} 
    bool HeapDumpOnOutOfMemoryError    = false        {manageable} 
    ccstr HeapDumpPath        =          {manageable} 
    uintx MaxHeapFreeRatio       = 100         {manageable} 
    uintx MinHeapFreeRatio       = 0         {manageable} 
    bool PrintClassHistogram      = false        {manageable} 
    bool PrintClassHistogramAfterFullGC   = false        {manageable} 
    bool PrintClassHistogramBeforeFullGC   = false        {manageable} 
    bool PrintConcurrentLocks      = false        {manageable} 
    bool PrintGC         = false        {manageable} 
    bool PrintGCDateStamps       = false        {manageable} 
    bool PrintGCDetails       = false        {manageable} 
    bool PrintGCID         = false        {manageable} 
    bool PrintGCTimeStamps       = false        {manageable} 
3

VM options美國這樣做的文章: - 標

標誌爲管理是動態可寫通過JDK 管理接口(com.sun.management.HotSpotDiagnosticMXBean API) 並且也通過JConsole。

找出所有這樣的標誌,你可以使用VM.flags那會

打印VM標誌選項及其當前值

-all作爲選項

打印VM支持的所有標誌

使用命令: -

jcmd <pid> VM.flags -all 
相關問題