Documentation

Quick start & JVM tuning

Recommended JVM memory flags, what to expect in Task Manager vs F3, and verifying v0.4.9 in-game.

Once mtr-memory-saver-0.4.9-mtr4.1.0-beta.2-mc1.21.1-neoforge21.1.265.jar is inside mods/, adjust your launcher memory cap and verify the mod in NeoForge.

For heavy collections (such as the 16-pack test fixture with 1,092 declarations / 2,541 legacy vehicles), start with:

-Xms512M -Xmx3072M -XX:+UseG1GC
  • -Xmx3072M (3 GiB) is the verified minimum heap cap for both startup and consecutive F3+T reloads.
  • If your modpack includes many terrain, shader, or non-MTR content mods alongside MTR, allocate 4 GiB (-Xmx4096M) so other mods have headroom.
  • Keep your resource pack ZIPs compressed or extracted as usual inside resourcepacks/ — Memory Saver handles deduplication and bounded streaming transparently at load time.

Java heap vs Windows process RAM

Players often inspect Task Manager alongside Minecraft’s F3 screen:

  • -Xmx3072M limits only the Java heap (steady sampled heap measured at 2.30–2.35 GiB across native-catalogue fixtures, and 2.07–2.65 GiB during isolated 0.4.9 in-world captures).
  • Native OpenGL buffers, Zlib/Deflater allocations, metaspace, and JVM overhead still live outside -Xmx. Total Windows Working Set / Private Commit on the 16-pack fixture runs around 4.25–4.47 GiB steady (and 4.39–5.86 GiB during heavy 20-reload stress cycles).

Verifying in-game

  1. Launch Minecraft 1.21.1 (NeoForge 21.1.265) and open Mods from the title screen.
  2. Confirm MTR Memory Saver displays version 0.4.9, Mod ID mtr_memory_sharing, the RAM-icon pack.png, and A-BenLi06 under authors.
  3. Join a world with MTR stations and trains, open F3, and verify your client runs stably under 3072MB allocated heap.

Reloading resource packs (F3+T)

Unlike unmodified MTR (or earlier 0.4.7 builds before single-channel generation cleanup), the streaming runtime in 0.4.9 / 0.4.8 atomically retires previous reload generations via beginReload() and keeps .bbmodel, .obj, and .mtl scratch channels DELETE_ON_CLOSE. In isolated -Xmx3072M validation, the identical 0.4.8 bytecode survived 20 / 20 consecutive F3+T reloads with zero OOMs.

Advanced Flags & Internals

For all 7 -Dmtr.memory.* JVM properties (reader/parser concurrency, queue depth, 96 MiB LRU budget) and the boundary between local cache budgets and total OS RAM, see Technical principles and Runtime contract & review.