Performance
Garbage Collection
Detailed guide to Java garbage collection tuning for Minecraft servers.
Garbage Collection (GC) is Java's automatic memory management system. Understanding GC helps you troubleshoot memory-related performance issues.
How GC Works
- Objects are allocated in heap memory
- When objects are no longer referenced, they become garbage
- The GC identifies and removes garbage, freeing memory
- New objects use the freed memory
Types of GC Events
| GC Type | Duration | Impact |
|---|---|---|
| Young GC (Minor) | ~1-50ms | Usually unnoticeable |
| Mixed GC | ~10-100ms | Brief pause |
| Full GC | ~100ms-5s+ | Significant lag spike |
Why Full GCs Are Bad
Full GCs scan the entire heap, which pauses all application threads. Frequent full GCs cause:
- TPS drops
- Player disconnects (timeouts)
- General unresponsiveness
Common Causes of GC Issues
- Heap too small: server uses all available memory
- Memory leak: plugin slowly accumulates unreleased objects
- High allocation rate: lots of temporary objects created per tick
- Too many loaded chunks: chunk data fills memory
Diagnosing GC Problems
- Check Spark health reports for GC data
- Look for frequent GC pause messages in server logs
- Monitor heap usage trends in the Pterodactyl Panel
- Run
/spark healthreport --memoryfor detailed memory analysis