MemoryFreeze Fix
A Fabric mod for Minecraft 1.21.11 that watches your JVM heap and steps in before it turns into a stutter or a permanent freeze loop.
Author: zSouul
What it actually does
- Visible stutter at ~100% - it forces a GC pass ("Panic Trim") once usage crosses a threshold (default 95%), before the game is forced into an emergency collection on its own.
- Getting stuck at high usage and never recovering ("Stuck detection") - if usage stays at/above a threshold (default 85%) for a sustained period (default 60s), it runs a multi-pass Deep Clean.
- The floor itself creeping up over a long session (e.g. never above 40% in the first hour, then stuck cycling 60→95% later) - that's not garbage, it's legitimately-referenced data (chunk/entity/render caches) accumulating with playtime, which GC can never reclaim. For that, use Full Reset.
The honest limits of this (please read)
A mod running inside the same JVM as the game cannot do anything a restart does that isn't already achievable with System.gc() alone — GC only reclaims objects nothing references anymore, it can't touch data Minecraft is still legitimately holding onto. So:
- If Deep Clean runs and usage barely moves, the mod will tell you so directly, instead of pretending it worked. That result means the memory is genuinely in use, not garbage waiting to be collected.
- Full Reset (/memoryfreeze reset, client-only, or the "Full Reset" keybind) is the real answer to that: it disconnects from the current world/server and immediately rejoins it, in the same running game. This is the same effect as the well-known "quit to title screen and rejoin" trick - it actually tears down the level (chunk trackers, entity data, render caches), which breaks the references GC couldn't touch, rather than just asking the GC to try harder. It's more disruptive than a Panic Trim or Deep Clean (you'll see a brief loading screen), so it's manual-only, never triggered automatically. If usage climbs right back to the same stuck floor immediately after a Full Reset, that's a strong signal of a genuine leak in another mod (not tied to world lifecycle) - no in-game trick fixes that, only removing/updating that mod or a real restart would.
- The single biggest lever for problem #1/#2 (usage climbing but never coming back down after a plain GC) is actually your JVM launch flags - specifically which garbage collector you're using and whether it's configured to hand memory back to the OS. That can't be changed at runtime by any mod. So on startup, this mod reads your current -Xmx and active GC algorithm and - only if they look suboptimal - logs (and shows once in chat) a concrete recommended JVM-arguments line. That's the actual root-cause fix; the in-game trim/deep-clean/reset are the safety net on top of it.
Requirements
- Fabric API 0.141.1+1.21.11 or compatible
- Cloth Config API 21.11.150+ (required : powers the config screen)
Commands
Works both as a server-side command (/memoryfreeze …, trim/deepclean/reload/hud require operator level 2) and as a client-side command with the same names, so it works identically in singleplayer and while connected to any server — the client-side version only ever touches your own client's memory.
| Command | Effect |
|---|---|
/memoryfreeze status |
Shows current heap %, used/committed/max, active GC, last trim/deep-clean times |
/memoryfreeze trim |
Manually runs a Panic Trim (single GC pass) right now |
/memoryfreeze deepclean |
Manually runs a Deep Clean (multi-pass, with an honest report) |
/memoryfreeze reset |
Client-only. Leaves and immediately rejoins the current world/server — the real "reset it" button, for when Deep Clean alone isn't enough |
/memoryfreeze reload |
Reloads the config file without restarting |
/memoryfreeze hud |
Toggles the on-screen heap meter |
There are also two unbound-by-default keybinds under Options → Controls → MemoryFreeze Fix - bind them to something convenient if you'd rather not type the commands:
- "Deep Clean Memory Now"
- "Full Reset (Leave & Rejoin World)"
Config
Edit it in-game via ModMenu → MemoryFreeze Fix → Config (if ModMenu is installed), or directly: auto-created on first run at .minecraft/config/memoryfreeze-fix.json. All values are live-editable and picked up with /memoryfreeze reload:
| Key | Default | Meaning |
|---|---|---|
panicTrimThresholdPercent |
95 | Heap % that triggers a Panic Trim |
panicTrimCooldownSeconds |
20 | Minimum gap between Panic Trims |
stuckThresholdPercent |
85 | Heap % considered "stuck" if sustained |
stuckDurationSeconds |
60 | How long it must stay stuck before auto Deep Clean fires |
reliefMinDropPercent |
4 | Minimum % drop needed to count as "relief" |
autoDeepCleanEnabled |
true | Whether stuck detection auto-triggers Deep Clean |
deepCleanCooldownSeconds |
60 | Minimum gap between Deep Cleans |
deepCleanMaxPasses |
3 | Max GC passes per Deep Clean |
pollIntervalMillis |
750 | How often the watchdog checks heap usage |
hudEnabled |
true | Show the on-screen heap meter |
chatNotifications |
true | Show a chat message when a trim/deep-clean happens |
logJvmAdviceOnStartup |
true | Log/announce a JVM-args recommendation if your setup looks suboptimal |

