"Too small maximum heap" Java error in Manjaro Linux running through terminal

Really don’t know what to do about this one. I’m trying to start a minecraft server with more RAM but the commands in the terminal give me this error.

The server works only if I go to the file manager and click on the server.jar file, it then boots up like normal with the GUI and everything. The problem is that I can’t set RAM parameters through there, only through commands.

I’ve tried:

sudo java -Xmx1024 -Xms1024 -jar server.jar

sudo java -Xmx4096 -Xms1024 -jar server.jar

sudo java -Xmx8164 -Xms1024 -jar server.jar

sudo java -Xmx1000000 -Xms1024 -jar server.jar

sudo java -Xmx3072 -Xms2048 -jar server.jar

sudo java -Xmx2048 -Xms512 -jar server.jar

sudo java -Xmx1024 -Xms512 -jar server.jar

sudo java -Xmx512 -Xms256 -jar server.jar

All result in the exact same error every time:

"Error occurred during initialization of VM"

"Too small maximum heap"

I’ve tried these with -nogui too, same error.

Asked By: kaiser kothe

||

The default value for the xmx and xms settings are in bytes so these values are way too small.

From man java:

-Xmsn
                Specify the initial size, in bytes, of the memory allocation
                pool. This value must be a multiple of 1024 greater than 1MB.
                Append the letter k or K to indicate kilobytes, or m or M to
                indicate megabytes. The default value is chosen at runtime
                based on system configuration. For more information, see
                HotSpot Ergonomics
                Examples:

                       -Xms6291456
                       -Xms6144k
                       -Xms6m

 -Xmxn
                Specify the maximum size, in bytes, of the memory allocation
                pool. This value must a multiple of 1024 greater than 2MB.
                Append the letter k or K to indicate kilobytes, or m or M to
                indicate megabytes. The default value is chosen at runtime
                based on system configuration. For more information, see
                HotSpot Ergonomics
                Examples:

                       -Xmx83886080
                       -Xmx81920k
                       -Xmx80m

So try:

sudo java -Xmx2048m -Xms2048m -jar server.jar

On a side note I recommend looking into Linux Game Server Managers if you aren’t already familiar. They have a series of scripts that make configuring and running game servers on linux very easy.

Answered By: jesse_b
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.