The advertised RAM belongs to the machine, not to the server
On a managed plan, the 4GB in the contract exist for the game process. On a VPS, those same 4GB pay for the kernel, systemd, sshd, the MariaDB you installed and only then the JVM. Anyone who sets Xmx4G on a 4GB machine watches the server run fine for a few hours and vanish overnight.
Vanish is the right word: with no memory left, the kernel kills the largest process, with no crash report, just the log stopping mid line. Reserve from 1GB up to a quarter of the RAM before setting Xmx, because the JVM still spends memory outside the heap on metaspace and thread stacks.