programmatically setting max java heap size

时光怂恿深爱的人放手 提交于 2019-11-28 01:57:08

Not with any Hotspot JVM. The JVM heap parameters can only be specified on the command line, and are then fixed for the lifetime of the JVM.

With Hotspot Java implementations, the only way to "change" the heap size of an application is to relaunch it in a new JVM with different command line parameters.

(I vaguely recall that JVMs from some other vendors do allow some heap parameters to be changed in a running JVM. Perhaps someone can clarify.)

You need to understand the difference between JVM space and the environment it runs in. The parameter that you have mentioned (and any other -X or -XX parameter) are environment set up provided by the environment that runs the JVM.

In an Windows XP machine, Windows OS is THE initiator of the JVM. Hence JVM should not be able to change a parameter that the OS provided. It's logical.

@Stephen C, may be you are right about some VM implementation that provide this feature, but I am not sure.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!