# --------------------------------------------------
# Minecraft Server JVM Arguments (SERVER)
# Target: Modded NeoForge server – 10GB RAM
# Java: 21
# --------------------------------------------------

# --------------------------------------------------
# 🛠️ Memory Allocation
# --------------------------------------------------
# Xms = minimum heap
# Xmx = maximum heap
# For a 10GB server, we keep headroom for OS and native memory.

-Xms8G
-Xmx10G

# --------------------------------------------------
# 🚀 Garbage Collector (G1GC – stable configuration)
# --------------------------------------------------

-XX:+UseG1GC
-XX:+ParallelRefProcEnabled
-XX:MaxGCPauseMillis=200
-XX:G1HeapRegionSize=16M
-XX:InitiatingHeapOccupancyPercent=30
-XX:G1ReservePercent=20

# --------------------------------------------------
# 🧠 Memory Management
# --------------------------------------------------

# Cap metaspace to avoid non-heap runaway with large modpacks
-XX:MaxMetaspaceSize=1024M

# Prevent mods or plugins from forcing full GC
-XX:+DisableExplicitGC

# Pre-touch memory pages at startup for more predictable performance
-XX:+AlwaysPreTouch

# Reduce duplicate String memory usage (useful for modded servers)
-XX:+UseStringDeduplication

# --------------------------------------------------
# 🔧 JVM / System Flags
# --------------------------------------------------

# Server environment, no GUI needed
-Djava.awt.headless=true

# Ensure consistent log and text encoding
-Dfile.encoding=UTF-8

# --------------------------------------------------
# ❌ Intentionally NOT used
# --------------------------------------------------
# -XX:MaxGCPauseMillis=50        (too aggressive, causes jitter)
# -XX:SurvivorRatio=32           (unnecessary with G1GC)
# -XX:MaxTenuringThreshold=1     (causes premature promotion)
# -XX:+UnlockExperimentalVMOptions (not needed in production)
# -XX:+UseCompressedOops         (automatic on Java 21)


# --------------------------------------------------
# ✅ How to Apply These Settings
# --------------------------------------------------
# 1. Open user_jvm_args.txt in your server folder.
# 2. Copy and paste these settings into the file.
# 3. Save the file and restart the server using run.bat.

# Your Minecraft NeoForge server is now optimized! 🚀
