Increase Heap Memory for WildFly – 增加WildFly的堆内存

最后修改: 2018年 8月 12日

中文/混合/英文(键盘快捷键:t)

1. Overview

1.概述

In this quick tutorial, we’ll have a look at how to increase the heap memory size for WildFly.

在这个快速教程中,我们将看看如何增加WildFly的堆内存大小

Naturally, increasing memory size can be useful in order to handle a large number of applications running on the server

当然,为了处理在服务器上运行的大量应用程序,增加内存大小可能是有用的

2. Using the Startup File

2.使用启动文件

In the standalone mode, we can update the configuration in the startup files to increase the heap memory.

在独立模式下,我们可以更新启动文件中的配置以增加堆内存。

In the WildFly installation home directory, we can find the standalone.conf (for Unix based systems) or standalone.conf.bat (for Windows systems) file in the bin folder.

在WildFly的安装主目录中,我们可以在bin文件夹中找到standalone.conf(基于Unix的系统)或standalone.conf.bat(Windows系统)文件。

We can simply open it and update the -Xmx option in the following line (change the number as per the requirement):

我们可以简单地打开它,并在下面一行中更新-Xmx选项(根据要求改变数字)。

JAVA_OPTS="-Xms64m -Xmx512m ..."

This will set the heap memory while starting up the server.

这将在启动服务器时设置堆内存。

3. Using an Environment Variable

3.使用环境变量

We can also set the default heap memory size by setting the JAVA_OPTS environment variable, which will override the value in the startup file. We can set the environment variable from a command prompt/ terminal.

我们还可以通过设置JAVA_OPTS环境变量来设置默认的堆内存大小,这将覆盖启动文件中的值。我们可以从命令提示符/终端设置环境变量。

For Windows:

用于Windows:

set JAVA_OPTS=-Xms256m -Xmx1024m ...

For Unix/Linux:

用于Unix/Linux:

export JAVA_OPTS=-Xms256m -Xmx1024m ...

Once this is set, we can see the result in the logs while starting the WildFly server:

一旦设置完毕,我们就可以在启动WildFly服务器时在日志中看到结果。

JAVA_OPTS already set in environment; overriding default settings with values ...

4. Conclusion

4.总结

In this quick tutorial, we found out how to change the heap memory size in WildFly quite easily.

在这个快速教程中,我们发现了如何在WildFly中很容易地改变堆内存大小。

You can explore different popular servers available for Java development in our previous article.

您可以在我们的上一篇文章中探索可用于Java开发的不同流行服务器。