I was trying to experiment with jcmd VM.set_flag option. But came across one error saying "only 'writeable' flags can be set". What are writable flags ?
Getting my pid:
XXX@XXX-Air:~/javacode$ jcmd -l
6294 Test
6295 jdk.jcmd/sun.tools.jcmd.JCmd -l
Trying to change vm flags:
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
Edit: It worked for manageable flags, below are successful commands.
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
Writable flags are labeled as {manageable}. You can list all flags with jcmd 12345 VM.flags -all. You can then grep for manageable ones (the is on my Oracle jdk8 VM) : Show activity on this post.
Impact: Medium — depends on Java content. VM.set_flag [arguments] Sets the VM flag option by using the provided value. Impact: Low Permission: java.lang.management.ManagementPermission(control)
You can list all flags with jcmd 12345 VM.flags -all. You can then grep for manageable ones (the is on my Oracle jdk8 VM) :
The command jcmd <process id/main class> <command> [options] sends the actual command to the JVM. Example 2-1 shows diagnostic command requests to JVM using jcmd utility. Example 2-1 Diagnostic Command Requests with jcmd Utility
Writable flags are labeled as {manageable}
.
You can list all flags with jcmd 12345 VM.flags -all
. You can then grep for manageable ones (the is on my 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}
The article over the VM options states this :-
Flags marked as manageable are dynamically writeable through the JDK management interface (
com.sun.management.HotSpotDiagnosticMXBean
API) and also through JConsole.
To find out all such flags you can use VM.flags
that would
Print the VM flag options and their current values
with the -all
as the option to
Prints all flags supported by the VM
using the command :-
jcmd <pid> VM.flags -all
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With