java在运行时动态增加xmx [英] java increase xmx dynamically at runtime

查看:701
本文介绍了java在运行时动态增加xmx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的机器中有一个jvm服务器,现在我想让我的两个服务器坐在同一台机器上,但是我希望备用服务器有一个非常少的内存分配xmx,因为它是被动的,一个是主机服务器(活动)出现故障我想为我的被动服务器分配更多内存,而无需重新启动它(我已经让它们都有太多的xmx - 请注意它们会在启动时消耗内存而我不能允许outOfMemory)。

I have a jvm server in my machine, now I want to have 2 apservers of mine sitting in same machine, however I want the standby one to have a really low amount of memory allocated with xmx because its passive, one the main server (active) goes down I want to allocate more memory to my passive server which is already up without restarting it (I have have them both having too much xmx - note they would consume memory at startup and I cant allow possibility of outOfMemory).

所以我想要被动 - 低xmx
一旦活跃下来我希望我的被动接收更多xmx。

So I want passive - low xmx once active goes down I want my passive to receive much more xmx.

我有办法实现这一目标。
谢谢

is there a way for me to achieve that. Thanks

推荐答案

这很好,但据我所知,它不是Sun提供的JVM选项。

It would be nice, but as far as I know it's not an option with the Sun provided JVMs.

Xmx选项是指定最大内存,它可以防止JVM占用整个机器的可用内存。如果要将其设置得更高,则不需要JVM分配所有内存。为什么不将它设置为一个非常高的数字并让JVM随着时间的推移而成长?

The Xmx option is to specify maximum memory, it's there to prevent the JVM from consuming the entire machine's free memory. If you want to set it higher, it won't require the JVM allocate all of that memory. Why not just set it to a very high number and let the JVM grow into it over time?

确保你的JVM不会以太少的内存开始(在将内存增加到所需大小时创建大量暂停,将Xms调整为您在启动时为JVM分配的大小。

To make sure your JVM doesn't start off with too little memory (creating lots of pauses as it grows the memory to the required size), adjust Xms to the size you want to allocate for the JVM at startup.

这篇关于java在运行时动态增加xmx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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