Memory Cleaner Mod
IMPORTANT:
THIS MOD IS NOT FOR EVERYONE!
Use it only when you experience lag due to high RAM consumption (usually happens with large modpacks) or game crashes caused by OutOfMemoryError.
In other situations, this mod may negatively affect your gaming experience, since forced memory cleanup takes time and provides no benefit if you have sufficient RAM.
For optimal performance, I recommend using the suggested JVM arguments, see below.
CLIENT ONLY MOD
This mod automatically triggers System.gc() to free up memory. Since forced garbage collection can cause temporary game freezes, the mod monitors player movement and starts cleaning RAM when the character remains idle for a while.
The memory cleaning process also activates when RAM usage exceeds the set threshold (configurable), or after a certain period if the above conditions are not met (also configurable).
Additionally, you can use the /cleanmemory command for immediate RAM cleanup.
More settings are available in the mod's configuration menu within the game.
Please note: do not add -XX:+DisableExplicitGC to your JVM arguments, as with this parameter the mod will completely stop working.
If you want to avoid game freezes during memory cleanup, try these JVM arguments: (-Xmx and -Xms values omitted)
-XX:+AggressiveOpts -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSConcurrentMTEnabled -XX:ParallelGCThreads=4 -Dsun.rmi.dgc.server.gcInterval=1800000 -XX:+UnlockExperimentalVMOptions -XX:+ExplicitGCInvokesConcurrent -XX:MaxGCPauseMillis=50 -XX:+AlwaysPreTouch -XX:+UseStringDeduplication -Dfml.ignorePatchDiscrepancies=true -Dfml.ignoreInvalidMinecraftCertificates=true -XX:-OmitStackTraceInFastThrow -XX:+OptimizeStringConcat -XX:+UseAdaptiveGCBoundary -XX:NewRatio=3 -Dfml.readTimeout=90 -XX:+UseFastAccessorMethods
These settings enable concurrent garbage collection, preventing game freezes during memory cleaning. JVM arguments can be configured in the Minecraft launcher.