#Java garbage collection working properly. Docker not.

1 messages · Page 1 of 1 (latest)

ivory wraith
#

Running into an issue where the container's RAM usage will increase over time but never decrease as Java executes garbage collection (Image #1). Server will crash (Image #2) and need to be Killed once the RAM cap is reached. Is there a fix for this using JVM arguments or something else?

java -Xms128M -XX:MaxRAMPercentage=85.0 -verbose:gc -Dterminal.jline=false -Dterminal.ansi=true $( [[ ! -f unix_args.txt ]] && printf %s "-jar server.jar" || printf %s "@unix_args.txt" )

tame gorge
#

i believe this is just a java thing, not in any way related to docker/pterodactyl. reduce the max ram percentage to something like 80 or 75

jovial tundra
ivory wraith
ivory wraith
tame gorge
#

yeah java is a bit finicky when in memory constrained environments

#

some of my servers are like 100mib away from the limit but are at 75% max memory amount

ivory wraith
#

I know that people are able to run successful MC servers using ptero. All I need to know is how.

ivory wraith
tame gorge
#

this specific server is running at 75% max memory percentage

ivory wraith
#

What is your uptime on that one?

#

And active player count/frequency?

tame gorge
#

3d 21h, though it will typically shoot up to that immediately as players join

#

22 players online right now with that

ivory wraith
#

Do you ever see the number go back down or does it stay at 7.57?

tame gorge
#

typically hovers around the maximum it reaches

#

if you're really that picky about java GCs memory usage, you can try shenandoah gc on compact mode

ivory wraith
#

Not picky hahaha, I just don't want the server to crash after a couple hours

tame gorge
#

well you can try it either way

#

this is in compact mode

#

though this is a lobby server

ivory wraith
#

You're running with Java 17 right?

tame gorge
#

some servers are running java 21, but yeah mostly 17

ivory wraith
#

I'll steal your JVM args 🤣

tame gorge
#

no problem, these are my args for my lobby

#

java -Xms128M -XX:MaxRAMPercentage=80 -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+DebugNonSafepoints -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact -XX:ShenandoahAllocationThreshold=60 -XX:+UseNUMA -XX:+AlwaysPreTouch -XX:+UseLargePages -XX:+UseTransparentHugePages -Dterminal.jline=false -Dterminal.ansi=true -jar server.jar

timid smeltBOT
#

Do not use the AlwaysPreTouch Aikar flag as it will preallocate all the memory and starve the container causing it to freeze or crash. Aikar's website warns of this.

Remove the flag or lower the Xmx to have overhead for the container, for example, with -Xmx$(({{SERVER_MEMORY}}-512))M

tame gorge
#

its ok support bot i know what im doing

ivory wraith
#

hahhaa you tell it

#

I'll try out your arg, thank you!

tame gorge
#

you may want to raise or lower ShenandoahAllocationThreshold depending on your servers allocation rate

#

if you've got a vanilla smp or modded server, i'd decrease it a bit

ivory wraith
#

modded on TerraFirmaGreg 1.20.1

tame gorge
#

beware that shenandoah will use more CPU usage than the default garbage collector

#

example in the lobby server

ivory wraith
#

Oh that's not too bad... We'll see how it performs on modded