Class DumpHeap

java.lang.Object
org.plumelib.util.DumpHeap

public class DumpHeap extends Object
Defines a static method dumpHeap(java.lang.String) that dumps the heap to an .hprof file.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static @MonotonicNonNull Method
    The method com.sun.management.HotSpotDiagnosticMXBean#dumpHeap.
    private static @MonotonicNonNull Object
    The HotSpot Diagnostic MBean.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Do not instantiate.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    dumpHeap(String fileName)
    Dumps a heap snapshot (of only the live objects) into a file.
    static void
    dumpHeap(String fileName, boolean live)
    Dumps a heap snapshot into a file.
    private static void
    Initialize the fields of this class.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • hotspotMBean

      private static volatile @MonotonicNonNull Object hotspotMBean
      The HotSpot Diagnostic MBean. Its type is Object, in case HotSpotDiagnosticMXBean is not available at compile time.
    • dumpHeapMethod

      private static @MonotonicNonNull Method dumpHeapMethod
      The method com.sun.management.HotSpotDiagnosticMXBean#dumpHeap.
  • Constructor Details

    • DumpHeap

      private DumpHeap()
      Do not instantiate.
  • Method Details

    • initializeFields

      @EnsuresNonNull({"hotspotMBean","dumpHeapMethod"}) private static void initializeFields()
      Initialize the fields of this class.
    • dumpHeap

      public static void dumpHeap(String fileName)
      Dumps a heap snapshot (of only the live objects) into a file.
      Parameters:
      fileName - file into which to dump a heap snapshot; is overwritten if it exists
    • dumpHeap

      public static void dumpHeap(String fileName, boolean live)
      Dumps a heap snapshot into a file.
      Parameters:
      fileName - file into which to dump a heap snapshot; is overwritten if it exists
      live - if true, dump only the live objects