What are the best JVM flags for a Minecraft Forge server?
My server's specs, very old I know:
Intel Core i5 4460
16 gigs of DDR3 RAM clocking at only 1600 MHz
1tb HDD (with 16 gigs of swap)
Now, I would like to optimize the server's performances and push it to the maximum without upgrading the hardware, that has a lot to be done.
I'm running a Forge 1.20.1 47.4.0 server with over 180+ mods (including a couple Fabric mods). One of the common issue is not MSPT or TPS (directly linked with the CPU) but rather RAM running out. Once RAM reaches its maximum allocated, the server becomes literally unplayable with rollbacks lasting like 100 seconds. This usually happens after people explore and generate chunks in different dimensions during the same session, like in the Twilight Forest and then the Ad Astra's moon dimension. I suspect that one of those mods just don't unload those dimensions from the memory, keeping the RAM perpetually clogged. One of the side effect of a full RAM is that it also slows down the system significantly, and that the garbage collector starts trying his best to clean any remaining bits from the RAM, thus costing a lot of CPU power.
I'm therefore looking for the best suited JVM flags for my server (i'm on JDK 21), cause I believe that I'm on default ones right now, but I do have some RAM optimisation mods like memorysweep, alltheleaks, memoryleakfix, ferritecore, etc.
68 Replies
Aikars
Aikars for any mc server
Only scenarios were aikars donโt work is on a proxy or smt like nanolimbo
Sorry to break it to you that server is not starting
wdym
alright
2013 CPU running 1.20 with 180 mods???
has anyone here used itzg's Docker server image?
Get a better server bro
it runs great
cope
I really doubt it
it has a MSPT of 40 with 1500 entities loaded and people exploring new chunks
that's like excellent
I had tps issues with an older version with only 40 mods on a DDR4 Xeon
for a little server with friends averaging 4-8 players CPU is not the issue
I donโt see how a budget consumer cpu from 13 years ago will run a newer version with so many mods and have no issues
RAM is
Then get more ram
priorities list here is
1. 32 gigs of RAM with higher clock speed
2. NVMe SSD (I'll replace the HDD first with a SATA for the time being)
3. Better CPU
Cant u just rent a server?
regarding the CPU I'm looking at an AMD Ryzen 5 5600x but you tell me if you have recommendations for a server
nah not fun
If you upgrade cpu you have to change everything so
Iโd start by that
Iโd get a 7600x
The extra money is worth it for another 3-5 years of potential upgrades
well of course and to have 32 gigs of DDR4 ram I would need to get a new mobo
Just get a new server
that's like twice as expensive as just upgrading the components over time
Not really because that cpu is not gonna be enough at some point so your gonna have to replace everything
And then u spent more then just getting a new server
not necessarily, what tells you that upon changing your CPU, you'll have to replace your GPU (because some servers do indeed need one), your RAM, your drives, your fans, your ventirad, your case, your power supply?
sometimes you don't even have to change your mobo because the socket stays the same
I think this is a flawed and consumerist logic but that's another debate
Your upgrading from an i5 from 2013โฆ.
Any change you make you need a new motherboard, new ram, new cooling, assuming you have one of those old optiplex machines then a new case and new psu
I was talking more generally, but then even with that CPU I don't have to replace everything lmao
also I don't know where you're getting that "optiplex" brand from
the server I have set up is a frankenstein mix of all of our old components from older gaming pcs
with a modern gaming case and fans
I have 3 GTX 980 in stock, couple DDR4 ram sticks, relatively recent (like 2020) gigabyte mobo, a SATA SSD, a bunch of gold and bronze power supplies i don't even know anymore, etc
there are a lot of components that I could just stick in to avoid buying everything to accommodate a new CPU
You do, pretty much just keep the drives
Usually people running 2013 intel hardware is cuz they bought and old used optiplex off marketplace
read what I've said next

Okay then do that
But get a new server
Donโt buy parts for the i5 thatโs a waste
I keep the fans, the PSU (that is literally overkill by hundreds of watts), the ventirad (doesn't matter much anyway just put an aggressive thermal paste :moderator:), the drives, that's already like 150 bucks saved no?
I mean if the psu is also from 2013
Change it
it's a gaming psu from 2019 probably
Okay
that was meant to support a GTX 1080
anyways, let's steer back on track
so AIKAR flags are better according to y'all, I was sold online that MEOWICE flags were more modern and suitable for Java 21 etc
thing is that I'm using the itzg minecraft server docker image. When I set "USE_AIKAR_FLAGS" to be true in the environment variables and recreate the container, nothing seems to change really.
Flags arenโt magic
If your issue is ram I doubt it will help much
You should change to Zulu though
I'm afraid that the reason there is no effect is because the flags are not being applied at all, look at this:

Omg and u installed a desktop?
๐ญ
Iโm pretty sure thatโs not the way you setup flags
as I said they wonโt help much
Try switching to Zulu too
bro can you fkin chill, this is my first server and I'm not planning to be a sysadmin, I just wanted to setup something for friends
this DE takes like 500 mbs of RAM while idling
what's wrong
itโs inecessary use of resources
ease of use and learning
Please tell me u installed Ubuntu server at least and then setup the desktop
You can perfectly use termius
Which has an interface for ssh and sftp
First it's debian 12, second yes XFCE was installed afterwards
I already have an openssh and sftp server running but I only use the latter because I prefer using it like an actual computer, but for the file transfer part I use an interface
Okay
ยฏ\_(ใ)_/ยฏ
I could've been on a server running Windows 11 Home edition with a RDS client, your statement would have still been pointless
again we don't care which OS or which linux distro I use, or whether I use a DE or not
if you're trying to assert some superiority complex because you use the latest tech in the industry, not with me please
that is not how I have set up the flags, this is a file that is output by the forge jar
which appears to be dumping all of the JVM flags it's running with, the Spark profiler dumps seems by the way to corroborate my claim

that's two sources telling me that JVM flags are not working at all
This is how you setup flags.

No Iโm trying to not make u waste the limited resources you have for no reason
Did u try Zulu?
Back when we used Java in production, we switched to Zulu and it helped quite well
Nope
because I don't see an option to switch the JDK build
I would've to rebuild the image by modifying the Dockerfile
40mspt isn't excellent to be fair, it means you only have 10mspt headroom before dipping below 20tps. For the age of the hardware, it's good though.
That is how you set them using forge packs with the included run script
they just append
@user_jvm_args.txt
to the java startup arguments, which loads the flags from the file and appends them
so they don't have users messing with the forge version specific arguments
Post a spark report if you're having issues with memory usageoh you using docker
well idk
usually just unilnstall default-jdk and install zulu
yeah I expected worse
wilco tomorrow
thanks for the recommendation I'll see tomorrow
i absolutely love to be recommended to spend money when thats not relevent to the question
op didn't ask for "performance fixes", the answer should be aikars and thats it
imagine asking whats the best steakhouse for $50 or below, and then being told that you are too poor
Spot on, thank you
I was totally aware that my hardware is very old (I even mentioned it in the original post), but I don't want to spend money for a 2 weeks phase minecraft server with friends
I just want to maximize the performances and give them the best possible experience
it was either this server or Aternos :pepecross:
๐
Aternos probably isnโt even an option considering they have like 10 mods from their catalog
pretty sure this intel core i5 fossil of a cpu ranks better than whatever Aternos uses as CPUs
Aternos server wouldn't even boot with 2 gigs of ram
Iirc their staff disclosed that ram is dynamically allocated, although I doubt that will actually make a difference
zero free host is gonna offer 8 gigs of ram which is the bare minimum for our modpack
And aternos did not openly disclose what hardware they run on, some older gen i7 or xeon I think
:xeondark:
They are meant for the 2 hour Minecraft phase, not 2 weeks โ ๏ธ
When you tryna use elytras on an Aternos server ๐
on the server we actually all use planes from immersive aircraft and it handles good
Although if you do happen to run into performance issues, you can use spark to see whatโs lagging
!spark
Spark Profiler
Spark can be used to see why your server or client is lagging.
Users can share a spark report via
/spark profiler start --timeout 300
which creates a report after 5 minutes. The spark report is useful in debugging why your server is lagging, so ideally you should always provide one while asking for support.
Download | Website | Docs
Admincraft Canned Responses
yep, I used spark a lot to optimise the server
without Spark i wouldn't have noticed that the nifty spiders mod is a horribly optimized mod, that single handedly took the TPS down to 2
it used like 80% of the server resources
Yeah some mods are just shit enclosed in a fancy package
It was probably doing multiple raycasts per tick per spider entity
if you know raycasts you start to see the issue