
Modrinth · Minecraft mod
MemGuard
Reduces RAM usage in large modpacks and servers by caching NBT strings, monitoring memory usage, and triggering garbage collection at optimal times.
Quick answer
Which MemGuard release should I use?
MemGuard 1.0.4 targets 1.21.1 with NeoForge. Installation on the client is optional. Installation on the dedicated server is optional. No extra mods listed for this file.
Where it goes
Is MemGuard required on the client, server, or both?
Installation on the client is optional. Installation on the dedicated server is optional.
The source marks this as usable on both the client and server.
What else does MemGuard 1.0.4 need?
1.0.4. Change the file and its required mods may change too.
This file does not list any required mods. Do not add a library just because a different file uses it.
This file does not list any required or optional mods.
Before you install it
Add MemGuard without breaking your instance.
Built for MemGuard 1.0.4. Pick another file and the loader, install side or required mods may change.
- 01
Stick to this file
Use 1.0.4. It targets 1.21.1 with NeoForge; another release may have different loader, side or dependency requirements.
- 02
Bring the mods it needs
This file does not list any required mods. Do not add a library just because a different file uses it.
- 03
Put it on the correct side
Installation on the client is optional. Installation on the dedicated server is optional.
- 04
Pick the file you checked
Use the “Get this file” button beside 1.0.4. It opens that exact file at the source.
About this project
What does MemGuard add?
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.
Project description from Modrinth.
Pick your setup
MemGuard by Minecraft version and loader
Choose the version and loader you play, then open the matching release.
1.21.10
2 loader builds1.21.9
2 loader builds1.21.8
2 loader builds1.21.7
2 loader builds1.21.6
2 loader builds1.21.5
2 loader builds1.21.4
2 loader builds1.21.3
2 loader builds1.21.2
2 loader builds1.21.1
2 loader builds1.21
1 loader buildShowing the newest 12 of 19 game versions. Older files are in the list below.
Check the dependencies, then try the file in a copied instance before changing a world you care about.
Recent files
MemGuard versions and loaders
1.0.4
memguard-1.0.4.jar
3 Jun 2026
1.0.2
memguard-1.0.1.jar
5 Apr 2026
1.0.2
memguard-1.0.2.jar
5 Apr 2026
1.0.3
memguard-1.0.3.jar
3 Apr 2026
Looking for an older file? The official Modrinth project page is in Resources.