Class HeapDumper

  • All Implemented Interfaces:

    
    public class HeapDumper
    
                        

    Class allowing access to Sun's heapDump method (Java 1.6+). Uses Reflection so that the code compiles on Java 1.5. The code will only work on Sun Java 1.6+.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static void init() Initialise the dumper, and report if there is a problem.
      static void dumpHeap(String fileName, boolean live) Dumps the heap to the outputFile file in the same format as the hprof heap dump.
      static void dumpHeap(String fileName) Dumps live objects from the heap to the outputFile file in the same format as the hprof heap dump.
      static String dumpHeap() Dumps live objects from the heap to the outputFile file in the same format as the hprof heap dump.
      static String dumpHeap(boolean live) Dumps objects from the heap to the outputFile file in the same format as the hprof heap dump.
      static String dumpHeap(File basedir, boolean live) Dumps objects from the heap to the outputFile file in the same format as the hprof heap dump.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • init

         static void init()

        Initialise the dumper, and report if there is a problem. This is optional, as the dump methods will initialise if necessary.

      • dumpHeap

         static void dumpHeap(String fileName, boolean live)

        Dumps the heap to the outputFile file in the same format as the hprof heap dump.

        Calls the dumpHeap() method of the HotSpotDiagnostic MXBean, if available.

        See HotSpotDiagnosticMXBean

        Parameters:
        fileName - name of the heap dump file.
        live - if true, dump only the live objects
      • dumpHeap

         static void dumpHeap(String fileName)

        Dumps live objects from the heap to the outputFile file in the same format as the hprof heap dump.

        Parameters:
        fileName - name of the heap dump file.
      • dumpHeap

         static String dumpHeap()

        Dumps live objects from the heap to the outputFile file in the same format as the hprof heap dump.

        Creates the dump using the file name: dump_yyyyMMdd_hhmmss_SSS.hprof The dump is created in the current directory.

        Returns:

        the name of the dump file that was created

      • dumpHeap

         static String dumpHeap(boolean live)

        Dumps objects from the heap to the outputFile file in the same format as the hprof heap dump.

        Creates the dump using the file name: dump_yyyyMMdd_hhmmss_SSS.hprof The dump is created in the current directory.

        Parameters:
        live - true id only live objects are to be dumped.
        Returns:

        the name of the dump file that was created

      • dumpHeap

         static String dumpHeap(File basedir, boolean live)

        Dumps objects from the heap to the outputFile file in the same format as the hprof heap dump. The dump is created in the specified directory.

        Creates the dump using the file name: dump_yyyyMMdd_hhmmss_SSS.hprof

        Parameters:
        basedir - File object for the target base directory.
        live - true id only live objects are to be dumped.
        Returns:

        the name of the dump file that was created