Package se.jiderhamn

Class HeapDumper

java.lang.Object
se.jiderhamn.HeapDumper

public class HeapDumper extends Object
Class that helps programatically dumping the heap. Heavily inspired by https://blogs.oracle.com/sundararajan/entry/programmatically_dumping_heap_from_java
  • Field Details

    • HOTSPOT_BEAN_NAME

      private static final String HOTSPOT_BEAN_NAME
      The name of the HotSpot Diagnostic MBean
      See Also:
    • HEAP_DUMP_EXTENSION

      public static final String HEAP_DUMP_EXTENSION
      Filename extension for heap dumps
      See Also:
    • hotSpotDiagnosticMBean

      private static volatile com.sun.management.HotSpotDiagnosticMXBean hotSpotDiagnosticMBean
      HotSpot diagnostic MBean
  • Constructor Details

    • HeapDumper

      public HeapDumper()
  • Method Details

    • dumpHeap

      public static void dumpHeap(File file, boolean live) throws ClassNotFoundException
      Dump the heap snapshot into a file.
      Parameters:
      file - The file in which the dump will be stored
      live - Dump only live objects?
      Throws:
      ClassNotFoundException
    • getHotSpotDiagnosticMBean

      private static com.sun.management.HotSpotDiagnosticMXBean getHotSpotDiagnosticMBean()
      Get HotSpot diagnostic MBean