
MemGuard
Reduces RAM usage in large modpacks and servers by caching NBT strings, monitoring memory usage, and triggering garbage collection at optimal times.
About this Mod
MemGuard
Lean memory behavior for long Minecraft sessions.
MemGuard is a lightweight utility mod for Fabric / Forge / NeoForge (Minecraft 1.21.1) focused on reducing avoidable allocations and making memory pressure easier to observe.
What MemGuard does
1. Reuses repeated short NBT strings
- Hook:
NbtString.of(...) - Repeated short values are reused through an LRU cache (up to 2048 entries).
- This reduces duplicate object allocations for common IDs/tags in larger modpacks.
2. Logs periodic heap snapshots
- Heap usage is sampled from server tick context.
- Warning logs are emitted when configured usage thresholds are exceeded.
- Intended for visibility and troubleshooting, not as a direct performance claim.
3. Tracks texture-atlas lifecycle (client)
- On atlas upload completion, MemGuard logs heap-used values in debug context.
- This helps correlate load phases with memory behavior.
Technical notes
- Uses mixin hooks for targeted behavior (
NbtCacheMixin,ServerChunkManagerMixin/ChunkCacheMixin,TextureCacheMixin). - No native code, no unsafe memory access.
System.gc()is not used to force garbage collection.
Important accuracy notes
- MemGuard does not guarantee fixed FPS/MSPT/MB improvements.
- Real impact depends on modpack size, entity/world state, JVM vendor/flags, and session length.
- Expected benefit is typically higher in medium/large packs with repeated NBT patterns.
Reproducible evaluation (recommended)
To evaluate MemGuard for your own setup, compare baseline vs. MemGuard under identical conditions:
- Same Java version, JVM args, mod list, world seed, and config.
- Same runtime window (recommended: 30-60 minutes per run).
- At least 3 baseline runs + 3 MemGuard runs.
- Collect comparable metrics:
- p50/p95 MSPT (
sparkor similar) - heap usage trend from logs
- allocation/GC event data (JFR or similar)
- Compare distributions (median/p95), not single spikes.
Installation
Fabric
- Install Fabric Loader (
0.16+) - Install Fabric API
- Place MemGuard jar in
mods/
Forge / NeoForge
- Install the matching loader for your Minecraft version
- Place MemGuard jar in
mods/
Compatibility
- Designed to work alongside common optimization mods.
- As with any mixin-based mod, test your exact modpack before production deployment.
Available Versions
How to Install MemGuard on Your Server
Order Server
Order a Minecraft Java server with at least 3 GB RAM (4 GB recommended).
Set fabric Loader
In the panel under "Egg", select the fabric loader and matching Minecraft version (1.21.11).
Install Mod
Open the mod browser in the dashboard and search for "MemGuard". Click "Install" – done! Alternatively, upload the .jar via SFTP to the /mods folder.
Compatibility
Mod Loaders
Minecraft Versions
1.21.11, 1.21.10, 1.21.9 (+16 more)
Server-side
✓ RequiredRecommended RAM
4 GB(min. 3 GB)Frequently Asked Questions
MemGuard server crashes on startup – what to do?
Most common cause: wrong fabric version or insufficient RAM. Check the server log (latest.log) for "OutOfMemoryError" or "Mixin" errors. With Mado Hosting: ensure at least 3 GB RAM is allocated and the loader matches the mod version (1.21.11). You can switch loaders with one click in the panel.
Is MemGuard compatible with fabric and forge and neoforge?
MemGuard officially supports fabric, forge, neoforge for Minecraft 1.21.11, 1.21.10, 1.21.9. Note: Forge and Fabric mods are NOT cross-compatible – pick one loader and stick with it. The Mado dashboard automatically detects incompatible loader combinations.
Server lagging with MemGuard – how to optimize performance?
Recommended RAM: 4 GB (per 8 players). Use /spark profiler to check if MemGuard consumes the most tick time. Common fixes: reduce server view-distance to 8-10, install "performant" or "starlight" as supplementary mods on Forge. With Mado Hosting, your server runs on NVMe SSDs with dedicated CPU cores for minimal latency.
Similar Mods
Rent Modded Server
Install MemGuard with just one click on your server.