Java 如何增加 WildFly 的堆内存?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24959128/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 15:59:17  来源:igfitidea点击:

How to increase heap memory for WildFly?

javaperformancewildflyheap-memory

提问by Manuela

WildFly 8 is started on a linux server with standalone.sh. I noticed that the server was started with very few heap memory space.

WildFly 8 在带有 standalone.sh 的 Linux 服务器上启动。我注意到服务器启动时堆内存空间很少。

I need to increase the heap memory space for the server and for applications, which are running on the server. How can I do it?

我需要为服务器和在服务器上运行的应用程序增加堆内存空间。我该怎么做?

采纳答案by Harald Wellmann

Just edit bin/standalone.conf, look for the first occurrence of JAVA_OPTSand change the -Xmxoption according to your needs.

只需编辑bin/standalone.conf,查找第一次出现JAVA_OPTS-Xmx根据您的需要更改选项。

回答by TomS

For managed domain you can set it using heaptag (e.g.<heap size="64m" max-size="512m"/>) within jvmin domain.xml or host.xml (depending on the scope you want to address).

对于托管域,您可以使用domain.xml 或 host.xml 中的heap标记(例如<heap size="64m" max-size="512m"/>)进行jvm设置(取决于您要寻址的范围)。

回答by satish

if wildfly 8 is used along with JDK 8, We need to add MaxMetaSpace Size. For example, JAVA_OPTS="$JAVA_OPTS -XX:MaxMetaspaceSize=256M" As we all know Java 8 does not support Perm gen setting. For related information, Please check Wildfly Heap issue

如果wildfly 8与JDK 8一起使用,我们需要添加MaxMetaSpace Size。例如 JAVA_OPTS="$JAVA_OPTS -XX:MaxMetaspaceSize=256M" 众所周知,Java 8 不支持 Perm gen 设置。有关相关信息,请查看 Wildfly Heap 问题

I hope it helps.

我希望它有帮助。

回答by Hett

On OS WINDOWSyou need setting standalone.conf.bat

OS WINDOWS你需要设置standalone.conf.bat

回答by Scutarius

I am running Eclipse and changing the 'bin/standalone.conf' didn't work for me. In this case the solution was oppening the 'Servers' view in Eclipse, double-click the Wildfly server, go to 'Open launch configuation' and do that changes there in 'VM argumments'. Anyway I am a bit noob with Wildfly, I hope other users could contrast my info, I found that in http://www.nailedtothex.org/roller/kyle/entry/articles-wildfly-jvmparams

我正在运行 Eclipse 并且更改“bin/standalone.conf”对我不起作用。在这种情况下,解决方案是在 Eclipse 中打开“服务器”视图,双击 Wildfly 服务器,转到“打开启动配置”并在“VM 参数”中进行更改。无论如何,我对 Wildfly 有点菜鸟,我希望其他用户可以对比我的信息,我在http://www.nailedtothex.org/roller/kyle/entry/articles-wildfly-jvmparams 中找到了

Its for a Linux server, but I think it could work for windows too.

它适用于 Linux 服务器,但我认为它也适用于 Windows。

回答by Saikat

Answer from official documentation:

来自官方文档的回答:

For a standalone server, you have to pass in the JVM settings either as command line arguments when executing the $JBOSS_HOME/bin/standalone.shscript, or by declaring them in $JBOSS_HOME/bin/standalone.conf. (For Windows users, the script to execute is %JBOSS_HOME%/bin/standalone.batwhile the JVM settings can be declared in %JBOSS_HOME%/bin/standalone.conf.bat)

对于独立服务器,您必须在执行$JBOSS_HOME/bin/standalone.sh脚本时将 JVM 设置作为命令行参数传递 ,或者通过在 $JBOSS_HOME/bin/standalone.conf. (对于 Windows 用户,要执行的脚本是%JBOSS_HOME%/bin/standalone.bat可以在 中声明 JVM 设置的%JBOSS_HOME%/bin/standalone.conf.bat

** Restart server to make this change effective.

** 重新启动服务器以使此更改生效。

回答by Dulith De Costa

Linux:

Linux

bin/standalone.conf

Check for the following line,

检查以下行,

JAVA_OPTS

and change it accordingly to suit your heap size needs

并相应地更改它以满足您的堆大小需求

-Xms1303m: initial heap size in megabytes
-Xmx1303m: maximum heap size in megabytes

JAVA_OPTS="-Xms1024M -Xmx2048M -XX:MaxPermSize=2048M -XX:MaxHeapSize=2048M"

Windows:

窗户

bin/standalone.conf.bat

JAVA_OPTS="-Xms1024M -Xmx2048M -XX:MaxPermSize=2048M -XX:MaxHeapSize=2048M"

Now restartthe server and it will work without prompting any heap size errors.

现在重新启动服务器,它将在不提示任何堆大小错误的情况下工作。