Java not releasing unused memory from Minecraft (PrismLauncher)

Operating System: EndeavourOS
KDE Plasma Version: 6.5.0
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 5800X 8-Core Processor
Memory: 32 GiB of RAM (31.2 GiB usable)

Someone on the Arch Forum referred me here.
So you all know, I’m a total arch noob and only use it since the beginning of October.
I bet someone is going to ask for logs, so I would appreciate it if you tell me where to find the ones needed.

What I did already:
Multiple System updates, fresh installations of Java and PrismLauncher, made a 2Gb swapfile and smaller things I just forgot.

As soon as I start Minecraft, the Java process uses more and more Ram until my pc runs out of it.

VirtualVM shows me that the Java process has a max heap of 8Gb (as I set it to), the size and what it uses, which all look normal but Systemmonitor shows what it overall uses or used.
The “Perform GC” button in VisualVm look that they work as intended, but I can’t see it in Systemmonitor.

I thought at first, that Systemmonitor maybe shows a different Java process or isn’t just precise, but when I kill/compare the process, VisualVm shows as well, that it is the same one.

I mainly try to play Vault Hunters and the mod to the Modpack prevents Minecraft to fully end, so I have to kill the process every time.
When not in use, Minecraft ends completely normal, as well as Java, but it will still accumulate RAM usage.

Last time I started Minecraft said
Systemmonitor that it uses 9.8Gb
VisualVM say it’s Heap size: 5.7Gb of which are 4.7 used and 8.4Gb is max
“free -m” says it got 32Gb overall / 8.5Gb used / 14Gb free / 461mb gemns. / 9.3Gb Puffer/Cache / 23Gb available

-Xms is set to 512mb

(idk what gemns. means, but maybe that is the german abbreviation for together)

I would suspect the mod installed is causing the memory leak. If you fire up a non-modded game does it still leak?

Also you might want to adjust the memory parameters if you are loading mods

I did some testing, without the Modpack specific Mods and in Vanilla it will still leak.
Even with Mods that are supposed to fix that, in the Vault Hunters Modpack and a separate one.
The specific Mods apparently only hinders Minecraft/java to end properly.

Same result if I use my own installation of Java 17 or the one that Prism Launcher downloads.

What version of java and version of minecraft are you using?

Java 17 and 1.18.2

For performance optimization, specific JVM arguments can be used to improve frame rate and overall performance, especially in modded environments. Recommended arguments include -XX:+UseG1GC for garbage collection, -XX:G1HeapRegionSize=32M for heap management, and -XX:MaxGCPauseMillis=50 to limit garbage collection pause times. Other beneficial flags include -XX:+UnlockExperimentalVMOptions , -XX:+UnlockDiagnosticVMOptions , and -XX:+AlwaysPreTouch to enhance memory management and reduce lag. It is advised to set the minimum and maximum heap size (-Xms and -Xmx ) to the same value to prevent memory resizing during gameplay.

Yes, I know, I already use those and Memory Leak fix mods.
If that worked, I wouldn’t have asked here.

-XX:+UseG1GC -Xmx8G -Xms8G -Dsun.rmi.dgc.server.gcInterval=600000 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32

Give those flags a try, assuming you have 16G or better for RAM

Runs even worse than before

I’m out of ideas. I’m running 1.21.10 server and don’t have issues. Newer versions of MC have trial chambers which seems similar to your mod for the old MC. Not sure. Never tried that mod.

I also run MultiMC with Fabric, Fabric API, Iris and Sodium and use a shader pack for the client side.

I would use a newer version of Java than 17, at least 21.

I run MultiMC with $ java --version
openjdk 21.0.9 2025-10-21

Minecraft 1.18.2 doesn’t run with anything newer than Java 17.
Minecraft version have specific Java versions, that isn’t new.

The problem doesn’t seem to be with Minecraft itself, but the Java installation/Prism Launcher Everything else runs fine, I know my things and my way around technology, if the solution would be that easy as to set JVM arguments I wouldn’t have asked here.

I guess open an issue with the dev on the mem leak fix