Cafora Docs
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

  1. Objects are allocated in heap memory
  2. When objects are no longer referenced, they become garbage
  3. The GC identifies and removes garbage, freeing memory
  4. New objects use the freed memory

Types of GC Events

GC TypeDurationImpact
Young GC (Minor)~1-50msUsually unnoticeable
Mixed GC~10-100msBrief 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

  1. Check Spark health reports for GC data
  2. Look for frequent GC pause messages in server logs
  3. Monitor heap usage trends in the Pterodactyl Panel
  4. Run /spark healthreport --memory for detailed memory analysis

See Also

On this page