I recently bought a Raspberry Pi 4 8GB and wanted to set up a Minecraft server on it.
However, as soon as I want to start Minecraft with more than 2GB Ram, I get this error:
"Invalid maximum heap size: -Xmx4G
The specified size exceeds the maximum representable size.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit. "
I use these start arguments: "java -Xms1G -Xmx4G -jar server.jar", normally I still use screen, but I have removed this so that I can see the error message.
I have Java like on this website: "https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-on-debian-10"
This is the confirmation:
"pi @ raspberrypi: ~ / minecraft $ java -version
openjdk version "11.0.9" 2020-10-20
OpenJDK Runtime Environment (build 11.0.9 + 11-post-Raspbian-1deb10u1)
OpenJDK Server VM (build 11.0.9 + 11-post-Raspbian-1deb10u1, mixed mode)
pi @ raspberrypi: ~ / minecraft $ javac -version
javac 11.0.9 "
So why is it now that I can only operate the Minecraft server with 2GB Ram?
I guess this is a 32bit Raspbian and / or the 32bit version of the JDK. This means that the RAM available for a process is limited (with Raspbian de facto to 3GB, although a JVM naturally needs more than just the Java heap).
Mhh okay… Is there a way to work around this?
Yes. A 64-bit operating system.
Okay thanks!