Java.lang.outofmemoryerror: Metaspace

I am on Paper 1.16.5 and every time with 5-7 players, the server starts saying this and plugins start spamming errors:

java.lang.outofmemoryerror: Metaspace
It does that, and when I do /tps the tps is at 18 and then the server crashes with the error: (I think this is what it says)

[PAPER WATCHDOG THREAD/ERROR] Server was forcibly stopped because it ran out of memory.
The server then shuts down

How can I fix this? I have 1.5 GB allocated. I am on a host that allocates only that much RAM (And they say that’s enough for 1.16)

Please help.

That’s not enough for 1.16. You should be using at least 6-10GB of RAM, but if you’re really scarce on resources, you can probably get away with 3-4 GB. You’ll want to find a host which allows for more ram, and this likely means you’ll have to pay for your server.

If you must use your current host, you can reduce the memory used by your server by decreasing the view distance in and delay-chunk-unloads-by in paper yml.

The view distance is 3, andn the delay-chunk-unloads is at default.
I just checked on my server and it was online and there was 1 player on the server and the plugins were enabling theirself and then disabling because the server ran out of memory again…

Like drbot said, a 1.16 server theses days recommand atleast above 3gb or ram. I host a small private survival server with about 11 plugins and 10 players and them alone take 4gb of ram.

Reducing your server settings even more won’t help you… you either need to get more ram. A minimum of 4-6GB is recommended even for just 1 player and that recommendation was made by one of the main contributor of Paper.

I just checked, and it has 2.1GB allocated and the server STILL manages to use up 2.1GB of ram

metaspace is not part of the heap, Xmx only controls the heap and does not account for the various other java regions or java itself
either your machine needs more ram, or, you need to increase the metadata allocation size, if not set, MaxMetaspaceSize will use as much as it can