org.apache.jorphan.util

## Class HeapDumper

- java.lang.Object
- - org.apache.jorphan.util.HeapDumper

-     public class HeapDumper
      extends java.lang.Object

  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+.

- - ### Method Summary

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

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### init

          public static void init()
                           throws java.lang.Exception

      Initialise the dumper, and report if there is a problem. This is optional, as the dump methods will initialise if necessary.
      Throws:
        `java.lang.Exception` - if there is a problem finding the heapDump MXBean

    - #### dumpHeap

          public static void dumpHeap(java.lang.String fileName,
                                      boolean live)
                               throws java.lang.Exception

      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. Must be creatable, i.e. must not exist.
        `live` - if true, dump only the live objects
      Throws:
        `java.lang.Exception` - if the MXBean cannot be found, or if there is a problem during invocation

    - #### dumpHeap

          public static void dumpHeap(java.lang.String fileName)
                               throws java.lang.Exception

      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. Must be creatable, i.e. must not exist.
      Throws:
        `java.lang.Exception` - if the MXBean cannot be found, or if there is a problem during invocation
      See Also:
        `dumpHeap(String, boolean)`

    - #### dumpHeap

          public static java.lang.String dumpHeap()
                                           throws java.lang.Exception

      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
      Throws:
        `java.lang.Exception` - if the MXBean cannot be found, or if there is a problem during invocation
      See Also:
        `dumpHeap(boolean)`

    - #### dumpHeap

          public static java.lang.String dumpHeap(boolean live)
                                           throws java.lang.Exception

      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
      Throws:
        `java.lang.Exception` - if the MXBean cannot be found, or if there is a problem during invocation
      See Also:
        `dumpHeap(String, boolean)`

    - #### dumpHeap

          public static java.lang.String dumpHeap(java.io.File basedir,
                                                  boolean live)
                                           throws java.lang.Exception

      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
      Throws:
        `java.lang.Exception` - if the MXBean cannot be found, or if there is a problem during invocation
      See Also:
        `dumpHeap(String, boolean)`

Copyright © 1998-2019 Apache Software Foundation. All Rights Reserved.