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 for any mc server Only scenarios were aikars donโ€™t work is on a proxy or smt like nanolimbo
Upioti
Upiotiโ€ข5mo ago
Sorry to break it to you that server is not starting
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
wdym alright
Upioti
Upiotiโ€ข5mo ago
2013 CPU running 1.20 with 180 mods???
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
has anyone here used itzg's Docker server image?
Upioti
Upiotiโ€ข5mo ago
Get a better server bro
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
it runs great cope
Upioti
Upiotiโ€ข5mo ago
I really doubt it
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
it has a MSPT of 40 with 1500 entities loaded and people exploring new chunks that's like excellent
Upioti
Upiotiโ€ข5mo ago
I had tps issues with an older version with only 40 mods on a DDR4 Xeon
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
for a little server with friends averaging 4-8 players CPU is not the issue
Upioti
Upiotiโ€ข5mo ago
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
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
RAM is
Upioti
Upiotiโ€ข5mo ago
Then get more ram
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
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
Upioti
Upiotiโ€ข5mo ago
Cant u just rent a server?
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
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
Upioti
Upiotiโ€ข5mo ago
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
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
well of course and to have 32 gigs of DDR4 ram I would need to get a new mobo
Upioti
Upiotiโ€ข5mo ago
Just get a new server
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
that's like twice as expensive as just upgrading the components over time
Upioti
Upiotiโ€ข5mo ago
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
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
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
Upioti
Upiotiโ€ข5mo ago
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
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
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
Upioti
Upiotiโ€ข5mo ago
You do, pretty much just keep the drives Usually people running 2013 intel hardware is cuz they bought and old used optiplex off marketplace
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
read what I've said next
Upioti
Upiotiโ€ข5mo ago
No description
Upioti
Upiotiโ€ข5mo ago
Okay then do that But get a new server Donโ€™t buy parts for the i5 thatโ€™s a waste
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
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?
Upioti
Upiotiโ€ข5mo ago
I mean if the psu is also from 2013 Change it
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
it's a gaming psu from 2019 probably
Upioti
Upiotiโ€ข5mo ago
Okay
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
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.
Upioti
Upiotiโ€ข5mo ago
Flags arenโ€™t magic If your issue is ram I doubt it will help much You should change to Zulu though
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
I'm afraid that the reason there is no effect is because the flags are not being applied at all, look at this:
No description
Upioti
Upiotiโ€ข5mo ago
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
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
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
Upioti
Upiotiโ€ข5mo ago
itโ€™s inecessary use of resources
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
ease of use and learning
Upioti
Upiotiโ€ข5mo ago
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
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
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
Upioti
Upiotiโ€ข5mo ago
Okay ยฏ\_(ใƒ„)_/ยฏ
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
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
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
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
No description
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
that's two sources telling me that JVM flags are not working at all
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
This is how you setup flags.
No description
Upioti
Upiotiโ€ข5mo ago
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
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
Nope because I don't see an option to switch the JDK build I would've to rebuild the image by modifying the Dockerfile
SilentBot
SilentBotโ€ข5mo ago
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 usage
Upioti
Upiotiโ€ข5mo ago
oh you using docker well idk usually just unilnstall default-jdk and install zulu
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
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
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
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
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
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
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
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
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
:xeondark:
๐’Ÿ๐‘œ๐“‚๐’พ๐“ƒ๐’พ๐’ธ
They are meant for the 2 hour Minecraft phase, not 2 weeks โ˜ ๏ธ
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
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
Carl-bot
Carl-botโ€ข5mo ago
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
From An unknown user
Admincraft Canned Responses
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
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
Wojtek le second
Wojtek le secondOPโ€ข5mo ago
It was probably doing multiple raycasts per tick per spider entity if you know raycasts you start to see the issue

Did you find this page helpful?