How can I allocate a dynamic amount of memory for my servers?

Hello PaperMC community,

I’ve noticed a resource inefficiency problem with running multiple servers with Waterfall at the same time.
You have to give a fixed amount of RAM to every server. That is bad, because if most people use server a, server b will need way less memory than it actually got reserved, so you won’t be able to use it, because of the worst case scenario.

My solution is to have, for example 8 Gb of RAM for all servers and then dynamicly allocating more resources to a more populated server. That way you will not have lag on them and every server would get enough memory.

BUT how can I do that? If you know the answer, please reply to this thread.

(Btw I use AdoptOpenJDK 11 with OpenJ9 and will switch to Java 17 when it comes out)

Thank you in advance!

you can’t, basically, such is how java works
you can use Xms to set a lower initial heap, but, then you lose performance gains from having fragmented memory, and then you’ve also got the risks of overallocation

The only real solution would be to schedule restarts on server is low on memory and change the values automatically.

I mean, yes you could do some hackery with the system but I wouldn’t recommend it.