MemorySweep

A utility mod that forces Java garbage collection on a timer or when memory usage crosses a threshold. The interval and threshold are configurable, and manual commands are provided.

📖 Introduction

MemorySweep is a utility mod that periodically forces garbage collection on the Java Virtual Machine that Minecraft runs on. What it does is simple: when a timer elapses, or when memory usage crosses a configured threshold, it calls System.gc() so that objects no longer being referenced get cleaned up.

There are two triggers. One is time-based auto-cleanup, defaulting to a 15-minute interval and adjustable in the config. The other is usage-based, defaulting to 75% memory usage. If you want to clean up right now, the commands /memorysweep_c (client) and /memorysweep_s (server) are available.

It works on both client and server. The mod page recommends pairing it with the -XX:+ExplicitGCInvokesConcurrent JVM argument, or using ZGC on Java 11+, to reduce the pause that a forced GC can cause.

One important caveat: MemorySweep does not increase your allocated RAM. It only brings cleanup forward within the heap you already have, so if the RAM you assigned to the modpack is simply too small, this mod won't fix that.

🕒 When to Use This Mod

When memory usage stays high after long sessions. It runs without any setup right after installation.

📦 Where It Matters Most

Large modpack setups where memory headroom is tight. Can be installed on both client and server.

🎮 How It Changes Your Playthrough

Gameplay itself does not change. The only visible sign is memory usage on the F3 screen dropping periodically.

🚀 Getting Started — First 30 Minutes

Step 1 — Leave it alone if your pack ships it. It runs immediately with the defaults (15-minute interval, 75% threshold).

Step 2 — Adjust the interval and threshold in the config if the defaults don't suit you.

Step 3 — Run /memorysweep_c or /memorysweep_s when you want an immediate sweep.

Next — Check your JVM arguments. Adding -XX:+ExplicitGCInvokesConcurrent, or switching to ZGC on Java 11+, reduces the pause a forced GC causes.

💡 Gameplay Tips

  • Works with defaults — 15-minute interval and a 75% threshold are the defaults, so it works out of the box.
  • Use the commands for an immediate sweep — /memorysweep_c (client), /memorysweep_s (server).
  • Pair it with JVM arguments — the mod page recommends -XX:+ExplicitGCInvokesConcurrent, or ZGC on Java 11+, to reduce the pause a forced GC causes.
  • RAM allocation comes first — if the heap itself is too small, no amount of GC will help. Check your launcher's RAM allocation first.

⚠️ Common Confusing Points

  • • It is not a mod that adds RAM — it only brings cleanup forward inside the heap you already allocated.
  • • A forced GC can cause a pause — calling System.gc() can stall briefly, which is exactly why the mod page recommends adjusting JVM arguments.

❓ FAQ

Does it increase RAM?

No. It only runs garbage collection earlier within the heap you already have. If the RAM you allocated to the pack is too small, raise the allocation in your launcher first.

How do I change the sweep interval?

The default is 15 minutes and it is adjustable in the config. Besides the timer there is a usage-based trigger, with a default threshold of 75%.

Can I trigger a sweep manually?

Yes — /memorysweep_c (client) and /memorysweep_s (server).

📦 Modpacks With This Mod

🔗 Related Mods