Wrong RAM suggestion
lufixSch opened this issue · 3 comments
Hi,
When setting up the server on a Raspberry Pi 4B+ with 8GB of RAM the script suggested 7.259GB.
Even though I only run the minecraft server on my Raspberry Pi it broke down, when starting chunky to pregenerate my world.
When decreasing the RAM to 6.8GB (max RAM - 10%) everything works fine.
Turn it way down. To like 2GB. This script was written for Pis that used less than 512MB. I would not be surprised if it performs better with the lower numbers because when things get tight (as you approach your maximum RAM) it has to shuffle things around a lot more which is slower.
Most 8GB systems would probably do fine to run the jar directly without any JVM arguments at all would be my guess.
It's not really wrong. It's a suggestion/recommendation based on the recommendations for this server which is headless meaning you aren't really running anything else. You have to apply things to your situation. The calculator can never take into account all of the circumstances of your server. For a dedicated server running nothing else (not even a GUI) you generally would put almost everything into it (i.e. a "dedicated server", in the most traditional sense of the term).
How many players are you expecting to have? What is the plugin load? Are other services running on the server? The SetupMinecraft.sh script could be 100 questions long and there would still not be a perfect calculator for this. At some point you are going to have to use some common sense and even some experimentation to see what works for you. If it's too much reduce it. If it's too little (pretty uncommon these days) then you need to give it more.
There's no "correct" answer to how much memory you need that can be calculated from a formula, and if anyone tried to give a formula or list of them I could tear it to shreds with things they had never even considered. I know from personal experience from these projects that when I think I've anticipated everything it turns out I had barely even scratched the surface of what people were doing with these scripts.
There is no need to choke your system for memory to this extent. Even 4GB would be extremely generous. If that's working well and there's memory going to waste after some run-time testing then you could bump it up to 5 or 6 and leave a nice big safe margin for all other applications/the system. Hopefully that helps!
Okay thank you for the explanation. I'm aware that your script can't take anything into account but on your website you wrote, that the script will automatically suggest the maximum available RAM minus 10% margin. So when executing the script I thought I could go with the recommendation.
It's not really wrong. It's a suggestion/recommendation based on the recommendations for this server which is headless meaning you aren't really running anything else.
I'm running headless so this shouldn't be a problem.
What you wrote about reducing the allocated RAM totally makes sense. I will definitely try it.
By the way, I really like this script. While I'm not new to Linux and the Raspberry Pi, it's the first time I set up a Minecraft Server. Your script saved me a lot of time getting started. So thank you!
Don't sweat it at all, I definitely can understand where you're coming from and you explained it really well here. To be honest if I wrote it today it would not have that at all (or really need it). The only people who may still need to fight with the memory are probably people with 1GB Pis. It's sort of a relic from back when we had Pis with < 1GB of RAM (and ONLY Pis with 1GB of RAM or less a few years ago).
Back then you had to literally allocate your memory budget by the percentage. Imagine what you were seeing with the memory really high but you would get lag/crashes like that if you were too high or too low by even 100MB or so.
These days it's far more likely to cause trouble (by people selecting too much, an understandable decision to allocate as much as possible for the best experience theoretically but because of the way Java manages memory it's not very straightforward and is often counterproductive to go with this seemingly logical decision) than anything.
My instinct is to remove it completely but I know there are definitely people running it on 1GB Pis out there. I doubt anyone is running it on anything less than that still but this level of tuning would still be required for those.
That's why it's a little bit of an anachronism though so I apologize for you getting caught up in that piece of it. I haven't made it "smarter" because I feel like we're 1 generation away from probably dropping that altogether so it has always seemed like a waste of time. It probably is time to start phasing it out though.
I could put the parameter at the top of the script as a manual override for anyone who still requires the functionality. This is probably the direction I'll move in for the early-2022-ish season so that nobody is cut off but it will eliminate the confusion as you are not the first one to ask me about this (I get a lot more comments on my web site than I do GitHub issues opened so I've seen it more over there).
Thanks for the kind words about the script. The feedback is much appreciated and I do want to make some changes here because of our conversation. Take care!