How to get Java8 Metaspace dump (not heap dump)

18,951

It seems you encounter a class loading 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.

The heap dump will also help, because each class in the Metaspace has a corresponding java.lang.Class instance in the heap.

Share:
18,951

Related videos on Youtube

czh
Author by

czh

Updated on June 14, 2022

Comments

  • czh
    czh almost 2 years

    Are there any tools that are able to get Metaspace dump from a Java8 hotspot vm ?

    • apangin
      apangin almost 8 years
      In which form would you like to get this and what for? Note that data in Metaspace are not Java objects. Probably you're not interested in HotSpot internal structures, but in something else.
    • czh
      czh almost 8 years
      We have an application causes Metaspace OOM error with 1G of MaxMetaspaceSize, and I wanted to know how Metaspace memories are being used.
  • czh
    czh almost 8 years
    Hi apangin, thanks for your advice. I was able to dump the entire heap using jmap -dump command, however I am struggling to run jhat command to analyze the dump file. The heap dump is about 5GB, and jhat has been running 2 hours without completion, is this normal?
  • czh
    czh almost 8 years
    jhat eventually terminated with heap space OOM error after running about 2 hours.
  • apangin
    apangin almost 8 years
    @czh Eclipse Memory Analyzer works fine even with large heap dumps.
  • Vishy
    Vishy almost 8 years
    @czh You can also try VisualVM or YourKit for larger heaps.
  • machinarium
    machinarium about 5 years
    How to interpret below statistics to know whether my fix of METASPACE OOM is working? Dump Reason : JCMD MaxMetaspaceSize : 536870912 B CompressedClassSpaceSize : 528482304 B Class Space Used : 21412264 B Class Space Capacity : 25373696 B Class Space Committed : 44572672 B Class Space Reserved : 1073741824 B NonClass Spaces Used : 178477376 B NonClass Spaces Capacity : 219028480 B NonClass Spaces Committed : 347594752 B NonClass Spaces Reserved : 348127232 B