In this quick tutorial, we'll have a look at how to increase the heap memory size for 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
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.
We can simply open it and update the -Xmx option in the following line (change the number as per the requirement):
JAVA_OPTS="-Xms64m -Xmx512m ..."
This will set the heap memory while starting up the server.
3. Using an Environment Variable
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.
set JAVA_OPTS=-Xms256m -Xmx1024m ...
export JAVA_OPTS=-Xms256m -Xmx1024m ...
Once this is set, we can see the result in the logs while starting the WildFly server:
JAVA_OPTS already set in environment; overriding default settings with values ...
In this quick tutorial, we found out how to change the heap memory size in WildFly quite easily.
You can explore different popular servers available for Java development in our previous article.