Useful Java memory and GC info

Submitted by kofa on Thu, 05/16/2013 - 13:41

According to Visualizing Java Garbage Collection by Ben Evans:

  • -Xms = -Xmx is no longer needed (set Xms to a reasonable value or omit it altogether; use -Xmx to limit maxium)
  • flags needed to produce useful GC logs:
    • -verbose:gc
    • -Xloggc:path-to-file (ensure you have enough space, can create logs over 1 GB)
    • -XX:+PrintGCDetails (can/should be used to replace -verbose:gc, yet he said all 4 flags are needed)
    • -XX:+PrintTenuringDistribution

From Everything I Ever Learned about JVM Performance Tuning @twitter by Attila Szegedi (now working for Oracle):

  • Throughput collectors: minimise total time spent in GC, at the expense of responsiveness (less frequent, but long pauses)
    • -XX:+UseSerialGC
    • -XX:+UseConcMarkSweepGC
    • -XX:+UseParallelGC
    • -XX:+UseParallelOldGC
    • Automatic tuning for throughput collectors (not for bulk services, but work pretty well in most other cases):
      • -XX:+UseAdaptiveSizePolicy
      • -XX:MaxGCPauseMillis=...
      • -XX:GCTimeRatio=...
  • Low-pause collectors (shorter pauses, but sum of GC times higher than with throughput collectors)
    • -XX:+UseConcMarkSweepGC (try if throughput + automatic tuning is not good enough)
    • -XX:+UseG1GC (note: according to Ben Evans, it is supported but not recommended by Oracle
  • Recommends diagnostic option -XX:+PrintHeapAtGC in addition to those suggested by Ben Evans

More presentations to extract info from (TODO): (lots of info on GC, not just Azul's)