Hello Kousi!
As far as I am aware, you can't change the -Xmx value at runtime. It is configured at JVM start up time. Here is a 10 minute that might give more insights in to JVM. JVM Explained in 10 minutes! - YouTube
Are there any options to dynamically adjust the value of -Xmx at runtime?
Hello Kousi!
As far as I am aware, you can't change the -Xmx value at runtime. It is configured at JVM start up time. Here is a 10 minute that might give more insights in to JVM. JVM Explained in 10 minutes! - YouTube
Hello Kousika,
Jelastic https://jelastic.com/ and INESC-ID http://www.inesc-id.pt/ have developed a patch for OpenJDK that improves the elasticity of JVM with variable loads.
To dynamically limit how large the committed memory (i.e. the heap size) can grow, a new dynamically user-defined variable was introduced: CurrentMaxHeapSize. This variable (defined in bytes) limits how large the heap can be expanded. It can be set at launch time and changed at runtime. Regardless of when it is defined, it must always have a value equal or below to MaxHeapSize (Xmx - the launch time option that limits how large the heap can grow). Unlike MaxHeapSize, CurrentMaxHeapSize, can be dynamically changed at runtime.
For example, dynamically set 1GB as the new Xmx limit
jinfo -flag CurrentMaxHeapSize=1g <java_pid>
Setting CurrentMaxHeapSize at runtime will trigger a full collection if the desired value is below the current heap size. After finishing the full collection, a second test is done to verify if the desired value is still above the heap size (note that a full collection will try to shrink the heap as much as possible). If the value is still below the current heap size, then an error is reported to the user. Otherwise, the operation is successful.
For more details, please visit the below articles:
https://mail.openjdk.org/pipermail/hotspot-gc-dev/2018-May/022077.html
https://openjdk.org/jeps/8204088
Edit your Comment