Server uses to much memory until crash in 1.18.1
CloudeLecaw opened this issue ยท 7 comments
Our Server has 22gb ram.
We tried to fill the map for a world with a bother of radius 5000
The ram increases instantly up the ram is filled completly and the server crashes because he is our of Memory.
Is there a chance to limit the amout of Ram used?
If not it needs to be fixed.
the inconsole text said ther where still 7 gb left but this is not the fact for us. the 7gb more ram are used for a secound miniserver bebcause the server source is splitted into two parts..
So what we would need is a setted max amount of RAM we can define for dynmap.
Any chance or possibillity for a fix?
PaperMC 1.18.1
Dynmap 3.3.0 Beta 2 (the latest for 1.18.1)
Here's my suggestions:
- Running out of memory when your JVM is configured for 22 GB but you say only 7 GB is being used is very broken - my first thought is your host doesn't have that much memory (e.g. you are letting your JVM think it can use 22 GB, but your host actually has 16 GB of memory). The virtual memory your host has available needs to be reduced by about 1 to 1.5GB when you determine how large Xmx can be - JVMs use memory besides that which is in the heap, and the JVM is just another process as far as Linux is concerned - if you hit the linux host's memory limit, the kernel's OOMKiller will kill the process without warning.
- The -Xmn setting is only 256M - I wouldn't suggest having this setting at all, as capping the young generation objects so much can also be causing problems
- For JVM flags, I'd suggest EITHER just the Xmx value (with Xms set to the same value), or use the 'Aikar flags) (Aikar is one of the prime guys on PaperMC, and has done loads of research on the 'best' flags for Minecraft servers) - see https://blog.airplane.gg/aikar-flags/ or https://aikar.co/2018/07/02/tuning-the-jvm-g1gc-garbage-collector-flags-for-minecraft/ (the latter being the original, which explains a lot of the details of his analysis
So what you the think is a issues?
We tested this reproducleable on the server now
with no other plugins installed (exept pex and latest protocollib) - same result..
So if you tested this with bigger maps(5gb+) then pls give a hind here.
Note: we result innthe same behave with the ram with worldborders fill plugin.
I have a PaperMC server running on a debian machine with 16GB of RAM. I have set the Xmx and Xms to 8GB.
I recently did a worldborder fill to a radius of 3500 blocks. Looking at the output of the top
command I saw that almost no memory was left ot the 16GB. In-game I got messages from the worldborder plugin that memory was full and that it is doing a cleanup (which freed about 1GB every time). the filling went through without any crashes although being a bit slower because of the limited memory. While doing dynmap fullrenders memory goes up too but it never crashes.
I observed that the whole minecraft server can take up a lot more memory than specified in the Xmx Xms flags so I would recommend setting it to about half of your actual available RAM. I remember that the server would crash in the past when I set the Xmx and Xms too close to the actual amount of RAM available in the past. Also now I use the 'Aikar flags' and since encountered way less problems.
I hope my experience can help you :D
"using all memory" is normal JVM behavior - you give it memory, it grows to use it, and it runs garbage collection when the junk memory accumulates enough to fill it - more memory, the less often this happens, but this is how Java has worked for the last 25 years...
Heap size (Xmx, Xms) is how much memory it will ask for from the OS - above and beyond the memory used by the native JVM components, libraries, and other task overhead: a minecraft server generally needs about 1 to 1.5 GB for this overhead, in addition to whatever memory is given to the heap (which is used for most java code related memory use, as opposed to the native use that is outside the JVM heap). If your host VM only allows N GB, you will want to set the heap of the JVM to between N-1 and N-1.5 GB, or else you WILL have problems with the JVM asking for memory from the host VM that it will not be given, which will also cause OOM conditions, or for it to be given more memory than the VM really has a quota for, which can cause the kernel to 'OOMKill' the JVM process (this often happens when more than one memory heavy process is started in the same host virtual machine, and their memory allocations exceed the total allowed.
"using all memory" is normal JVM behavior - you give it memory, it grows to use it
Much like with Linux: if there's free RAM, it'll use it as cache to speed up the system, but if a process requires that memory, the kernel frees it up for that process.
Running JVM with -Xmx22G
on a server with 22G of memory will cause OOM errors - this is expected and by design, even if you didn't have a second service running on the same machine. It is literally the expected behavior.
Set your -Xmx
to 8G on both servers you run, that will have 16GB allocated to JVM heap and leave 6GB of headroom for any other types of allocation, as well as I/O cache and other system services.