MemGuard
ModReduces RAM usage in large modpacks and servers by caching NBT strings, monitoring memory usage, and triggering garbage collection at optimal times.
Description
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.
Compatibility
Mod Loaders
Game Versions
Recommended Gear
AffiliateHardware and extras that pair well with this mod.
As an Amazon Associate I earn from qualifying purchases.
Similar Mods
Modern Jujutsu
A complete, client-side visual overhaul for the JujutsuCraft mod. Replaces the default HUD with a sleek, modern, and hig...
Revamped Shipwrecks (Mod)
Shipwreck structures redesigned with jigsaw degradation stages, hundreds of unique combinations!
Graphene
Optimize entities and rendering
More Swords Mod
A simple mod that adds new swords and enchantments into the game.
Misc Additions
Miscellaneous additions that fit into Vanilla Minecraft
Female Gender & Age Mod
ARCHIVED/DISCONTINUED. Adds player age and gender settings to Minecraft. Uses new hurt sounds, female models and texture...
Included in Modpacks (20)
Project 4J
Crafted Madness: Modern Era
Create: Constructs of the Wild
MAJNR: WORLD (Official)
Yet Another Horror Pack
Kryeit Gold
Create OneBlock | by Saurier.xyz
Eclipse Client
DrUltraLux's Steam Fantasy
CreateMore
BiteForceMC Cobblemon
FlamePack Re-Vulkanized
Vanilla Expanse
Farbound
Create Elements 6
LlamaWorld
Create Aeronautics++
Create Vestro
Bartoleros
Horror Colonies