Modify JVM args from inside the JVM

前端 未结 7 1273
野的像风
野的像风 2020-12-21 07:39

Is there a way to modify the jvm args from inside of the jvm? Specifically, I want to be able to change the maximum heap size of the jvm from inside of it. Is this possibl

7条回答
  •  独厮守ぢ
    2020-12-21 08:23

    As noted by others, this is generally only possible by having a bootstrap program (Java or other language) that invokes the main JVM with the right parameters.

    That said, are you sure this is necessary? You mention "maximum heap size". If you are referring to the -Xmx parameter: This is just a limit the VM may never exceed. It does not mean the VM will really use that much, it will do with less if it can.

    So you can always set -Xmx to the maximum the system can handle, and let the JVM decide how much it really needs. Why do you think you need to set it dynamically?

提交回复
热议问题