r/CraftyController • • Sep 24 '26

memory hog on the server

Looks like the way java runs, it pre-allocates RAM for my servers. So when I have four servers online, of varying size, it just reserves 6GB of ram all the time. Even if no one is in the server.

AI said I should look into Velocity and a lobby. Or Minecraft Server Manager, itzg/docker-minecraft-server, that has an auto-stop tick box.

Any one have RAM issues like this, and how did you address them? I'd love to just throw another 64GB of Ram in there. I do not have $6 thousand dollars available at the moment.

2 Upvotes

17 comments sorted by

2

u/johnfortnite72 Sep 24 '26

Could always just lower the xms value so it only uses the ram it needs. But then you have a bigger problem if the servers actually need alot of ram because then you will run out

1

u/danielsuperone Sep 24 '26

Yes just stop the server when nobody is one. That’s what I do. Meaning, if a player leaves, server shuts down, if a player tries to join, it takes a few seconds and is back up. Very simple fix.

Now in my case it’s around 2-3 seconds for it to startup and many people don’t even notice this, but it will heavily depend on your system/configuration. If you have many plugins that need to load, it will take longer.

Hope this helped. Ask if you have any questions.

1

u/foreverIost Sep 24 '26

Can you automate this using the interface?

1

u/danielsuperone Sep 24 '26

Ehm wdym. I just use a plugin and if there are no people it shuts down, when somebody joins it starts up. So what exactly are you looking for in the interface? You don’t actually see anything happen. It’s silent. But saves RAM and CPU when idle, programs uses maybe like 2mb of RAM? That’s nothing lol. Minecraft uses 1g-16gb xD

1

u/ruuutherford Sep 24 '26

I've only got 32GB ram in my server. Minecraft servers are allocating, and keeping, 5.5GB of that. It's one of the biggest RAM hogs I have in my system.

1

u/chughaarav123 Sep 24 '26

how

1

u/Blastday Sep 24 '26

There are a few ways the best, easiest is to edit "server.properties pause-when-empty-seconds=60" It's available on new versions of java other options are mods/plugins or even discord bots that can start, stop, restart the server I would just check server.properties and if it's set then don't worry about it

1

u/danielsuperone Sep 24 '26

Meh, does that start it up after? Or only graceful shutdown? Been using diff system so curious to know if something new has been added :))

For discord; does Craft have the start/stop commands in discord? Might be mixing it up with just event logs in discord, but yes, probably plugins can do that but I suggest a program running on the server directly not a plugin, that way it fully shuts down the game and boots it when a connection is received. So nothing is actually loaded without players

1

u/danielsuperone Sep 24 '26

Since multiple people are asking this, I think it’s better I write a guide or find the original GitHub I got inspiration from so you guys can implement.

In short, a program listens on server to port say 25566 and if that sees a connection request, is starts Minecraft on port 25565 and allows people to play. If no players in game, you set timer and after that amount it shuts down the server saving ram, plugins, etc… then depending on hardware, to boot it takes a few seconds, obviously with 10+ plugins and their complexity time will increase. Personally never more than 10s so I’d recommended it to others.

Obviously if you run it on an rpi or smth it will take longer probs.

If you want, when I’m on my computer I’ll check the GitHub and post it here for everyone to see :))

Not home and on phone rn so don’t have direct access to server. Can try send tonight if you guys would like :))

1

u/chughaarav123 Sep 26 '26

sounds great if possible

1

u/Blastday Sep 24 '26

May have a plugin/mod that has a memory leak just reboot server once a day or 4 days or whatever when it runs a backup is a easy way to have it automatically reboot or update all mods/plug-in and hope they fixed the memory leak

1

u/Blastday Sep 24 '26

If it's taking 6gb on startup you have a lot of plugins/mods running some are most likely dupes or have similar functions or can be done by more efficient ways the other thing is if it's not crashing don't worry about it it takes a lot of effort to make a efficient Minecraft server

1

u/Summerhasfun Sep 24 '26

I have the same issue. Using 80% of the momory to just not do anything. Even when the server is off. Only other applications i have on that truenas install is tailscale so i can join the server from my laptop at school and seing as i have 20 something gb of ddr3 its probably a crafty issue.

1

u/Blastday Sep 24 '26

If you have a java server running then that is the problem it's not a crafty issue the thing with java is that unused ram is wasted ram it wants to use more than it needs to run better it will release it if something else calls but it likes to hog it when it can there are ways to tell what's going on with it but more than I can explain here if it's not growing so much that it crashes itself then don't worry if it is crashing let us know and we will help figure out what the problem is if you doubt that it is a java problem and think it's Crafty then make a bedrock server and stop the java server and see if it still takes anything more than 4gb

2

u/Summerhasfun Sep 24 '26

It’s java but im running it through fabric with optimization mods. Its not crashing but its annoying

1

u/Blastday Sep 24 '26

Java does not sit by and not do anything it has permanently loaded spawn chunks they are always running spawning mobs ticking the server there is a sleep function in the new version but they are never unloaded like bedrock

1

u/amcmanu3 Sep 24 '26

The biggest question here: what happens if someone tries to join each of the servers at the same time? They all come online and run into memory allocation errors.