Java: non-heap-memory analyzes

Non-heap memory usage, as provided by MemoryPoolMXBean counts the following memory pools:

  • Metaspace
  • Compressed Class Space
  • Code Cache

In other words, standard non-heap memory statistics includes spaces occupied by compiled methods and loaded classes. Most likely, the increasing non-heap memory usage indicates a class loader leak.

Use

  • jmap -clstats PID to dump class loader statistics;
  • jcmd PID GC.class_stats to print the detailed information about memory usage of each loaded class. The latter requires -XX:+UnlockDiagnosticVMOptions.

Leave a Comment