Yes, there is a maximum, but it's system dependent. Try it and see, doubling until you hit a limit then searching down. At least with Sun JRE 1.6 on linux you get interesting if not always informative error messages (peregrino is netbook running 32 bit ubuntu with 2G RAM and no swap):
peregrino:$ java -Xmx4096M -cp bin WheelPrimes
Invalid maximum heap size: -Xmx4096M
The specified size exceeds the maximum representable size.
Could not create the Java virtual machine.
peregrino:$ java -Xmx4095M -cp bin WheelPrimes
Error occurred during initialization of VM
Incompatible minimum and maximum heap sizes specified
peregrino:$ java -Xmx4092M -cp bin WheelPrimes
Error occurred during initialization of VM
The size of the object heap + VM data exceeds the maximum representable size
peregrino:$ java -Xmx4000M -cp bin WheelPrimes
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
(experiment reducing from 4000M until)
peregrino:$ java -Xmx2686M -cp bin WheelPrimes
(normal execution)
Most are self explanatory, except -Xmx4095M which is rather odd (maybe a signed/unsigned comparison?), and that it claims to reserve 2686M on a 2GB machine with no swap. But it does hint that the maximum size is 4G not 2G for a 32 bit VM, if the OS allows you to address that much.
Answer from Pete Kirkham on Stack OverflowYes, there is a maximum, but it's system dependent. Try it and see, doubling until you hit a limit then searching down. At least with Sun JRE 1.6 on linux you get interesting if not always informative error messages (peregrino is netbook running 32 bit ubuntu with 2G RAM and no swap):
peregrino:$ java -Xmx4096M -cp bin WheelPrimes
Invalid maximum heap size: -Xmx4096M
The specified size exceeds the maximum representable size.
Could not create the Java virtual machine.
peregrino:$ java -Xmx4095M -cp bin WheelPrimes
Error occurred during initialization of VM
Incompatible minimum and maximum heap sizes specified
peregrino:$ java -Xmx4092M -cp bin WheelPrimes
Error occurred during initialization of VM
The size of the object heap + VM data exceeds the maximum representable size
peregrino:$ java -Xmx4000M -cp bin WheelPrimes
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
(experiment reducing from 4000M until)
peregrino:$ java -Xmx2686M -cp bin WheelPrimes
(normal execution)
Most are self explanatory, except -Xmx4095M which is rather odd (maybe a signed/unsigned comparison?), and that it claims to reserve 2686M on a 2GB machine with no swap. But it does hint that the maximum size is 4G not 2G for a 32 bit VM, if the OS allows you to address that much.
I think a 32 bit JVM has a maximum of 2GB memory.This might be out of date though. If I understood correctly, you set the -Xmx on Eclipse launcher. If you want to increase the memory for the program you run from Eclipse, you should define -Xmx in the "Run->Run configurations..."(select your class and open the Arguments tab put it in the VM arguments area) menu, and NOT on Eclipse startup
Edit: details you asked for. in Eclipse 3.4
Run->Run Configurations...
if your class is not listed in the list on the left in the "Java Application" subtree, click on "New Launch configuration" in the upper left corner
on the right, "Main" tab make sure the project and the class are the right ones
select the "Arguments" tab on the right. this one has two text areas. one is for the program arguments that get in to the args[] array supplied to your main method. the other one is for the VM arguments. put into the one with the VM arguments(lower one iirc) the following:
-Xmx2048mI think that 1024m should more than enough for what you need though!
Click Apply, then Click Run
Should work :)
Best values for min-max RAM, Xms & Xmx arguments
Java process consuming more memory than assigned Max heap
A way to better limit the JVMs memory usage (-Xmx alone isn't enough)
Many librairies use native code and off heap memory. And some tools are done for that, like Cassandra for example that will by default use very much more off heap than heap memory.
More on reddit.comInitial heap size set to a larger value than the maximum heap size
Videos
Edit: Solved, just set them both to the same value!
---
So when running my server (which has 8GB or RAM) I set my Xms to 2G (minimum RAM) and Xmx to 6GB (maximum RAM). From what I understand this means the server will always use 2GB of RAM but can take up to 6GB if it needs it. It's running on a dedicated Ubuntu server that does nothing but run the MC server, so 2GB for the OS etc. should be fine.
However, I've also read that giving MC too much RAM is bad, and garbage collection will go haywire. I managed to find some good but very cheap RAM so I'll be upgrading to 16GB of RAM this weekend.
My question is, how to determine what to set the min RAM to and what the max RAM? I just picked 2GB as the minimum value at random, as it seemed like a good amount to give the server at minimum. When I put the 16GB in I want to allocate 12GB to my MC server, should I keep the min at 2GB and set the max to 12GB? Could this lead to issues?
My launch parameters (added some line breaks for readability):
java -server -Xms2G -Xmx6G -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:MaxGCPauseMillis=100 -XX:+DisableExplicitGC -XX:TargetSurvivorRatio=90 -XX:G1NewSizePercent=50 -XX:G1MaxNewSizePercent=80 -XX:G1MixedGCLiveThresholdPercent=35 -XX:+AlwaysPreTouch -XX:+ParallelRefProcEnabled -Dusing.aikars.flags=mcflags.emc.gs -jar $(ls -v | grep -i "FTBServer.*jar\|forge.*jar\|paper-*.*jar\|spigot-*.*jar\|minecraft_server.*jar" | head -n 1) nogui
Hi guys, hole you are having a good day.
We have an AWS ec2 server 32 GB memory and 4 core CPU. There we are running multiple Java processes with xms and xms defined. But the amount of memory consumed by the Java processes are much higher than the xmx value we have set.
We know that jvm itself consumes memory, but in some scenarios it's piculierly high. For example we have set xmx as 2GB and it's consuming 4GB approx.
How to fix this issue?
Note: we are using Java openjdk 11 latest patch to date
Any help is much appreciated, thanks in advance