从JVM内部修改JVM args [英] Modify JVM args from inside the JVM

查看:170
本文介绍了从JVM内部修改JVM args的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法从jvm里面修改jvm args?具体来说,我希望能够从内部更改jvm的最大堆大小。这可能吗?

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 possible?

编辑:我想我应该添加我想要这样做的原因。我有一些在不同的机器/平台上运行的Java程序。这些程序具有在运行时获取的配置,并且根据程序运行的计算机/环境而不同。其中一些配置可以在运行时更改,各种程序会随着配置的更改自动更新。

Edit: I guess I should add the reason I wanted to do this. I have a few Java programs that are run on different machines/platforms. These programs have configurations that are sourced at runtime and are different depending on the machine/environment the program's running one. Some of these configurations can be changed at runtime and the various programs automatically update themselves as the configurations change.

我希望堆大小成为这些配置参数之一在运行时像配置的其余部分一样。如果是这样,那么程序可以启动(使用一些默认的jvm args)然后根据检索到的配置调整自己。

I wanted heap size to be one of these configuration parameters that is sourced at runtime like the rest of the configuration. If so, then the program could startup (with some default jvm args) then adjust itself based on the retrieved config.

推荐答案

这个是一个半途而废的,彻头彻尾的黑客想法:

This is a halfway-serious, completely-off-the-wall hack-thought:

...如果你产生了一个新的java实例(使用新的设置)会怎么样?从目前的jvm然后杀死旧的进程从新?我不知道这是否会有所帮助(或甚至工作)......

...what if you spawned a new instance of java (with the new settings) from the current jvm then killed the old process from the new? I have no idea if this will help or not (or even work)...

这篇关于从JVM内部修改JVM args的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆