How to increase Java runtime maximum heap memory?

CaffeineAddict

Well-Known Member
Joined
Jan 21, 2024
Messages
2,499
Reaction score
2,045
Credits
20,243
The following output is excerpt from command: java -XshowSettings

VM settings:
Max. Heap Size (Estimated): 3.86G
Using VM: OpenJDK 64-Bit Server VM

This according to my understanding means that Java applications will be limited to 4GB of memory, however my system has 16GB and I want to increase it to at least 8GB because I need it for a game.

My attempt so far was this:
According to man java we can specify -Xmx option to specify max Heap Size and -Xms option to specify minimum size, so I entered the following into my .bashrc:

export JAVA_OPTS="-Xms6G -Xmx8G"

However this doesn't work, obviously because reported max is 4GB from the output of java -XshowSettings
How do I properly modify these settings?

I'm on Debian.
 


you can specify the heap size directly when running your Java application:

Code:
java -Xms6G -Xmx8G -jar your-application.jar

You can put this in a bash shell script or systemd service file to launch your application.
 
The game is written in Kotlin language and is run from Lutris.

In that case, I suspect these are compiled with something like gradle or maven
and the parameters would be compiled into the launcher.
 


Members online


Top