/** * Dumps live objects from the heap to the outputFile file in the same format as the hprof heap dump. * <p> * @see #dumpHeap(String, boolean) * @param fileName name of the heap dump file. Must be creatable, i.e. must not exist. * @throws Exception if the MXBean cannot be found, or if there is a problem during invocation */ public static void dumpHeap(String fileName) throws Exception{ dumpHeap(fileName, true); }
/** * Dumps the heap to the outputFile file in the same format as the hprof heap dump. * <p> * Calls the dumpHeap() method of the HotSpotDiagnostic MXBean, if available. * <p> * See * <a href="http://docs.oracle.com/javase/7/docs/jre/api/management/extension/com/sun/management/HotSpotDiagnosticMXBean.html"> * HotSpotDiagnosticMXBean * </a> * @param fileName name of the heap dump file. Must be creatable, i.e. must not exist. * @param live if true, dump only the live objects * @throws Exception if the MXBean cannot be found, or if there is a problem during invocation */ public static void dumpHeap(String fileName, boolean live) throws Exception{ getInstance().dumpHeap0(fileName, live); }
/** * Initialise the dumper, and report if there is a problem. * This is optional, as the dump methods will initialise if necessary. * * @throws Exception if there is a problem finding the heapDump MXBean */ public static void init() throws Exception { Exception e =getInstance().exception; if (e != null) { throw e; } }
/** * Dumps live objects from the heap to the outputFile file in the same format as the hprof heap dump. * <p> * Creates the dump using the file name: dump_yyyyMMdd_hhmmss_SSS.hprof * The dump is created in the current directory. * <p> * @see #dumpHeap(boolean) * @return the name of the dump file that was created * @throws Exception if the MXBean cannot be found, or if there is a problem during invocation */ public static String dumpHeap() throws Exception{ return dumpHeap(true); }
/** * Dumps objects from the heap to the outputFile file in the same format as the hprof heap dump. * <p> * Creates the dump using the file name: dump_yyyyMMdd_hhmmss_SSS.hprof * The dump is created in the current directory. * <p> * @see #dumpHeap(String, boolean) * @param live true id only live objects are to be dumped. * * @return the name of the dump file that was created * @throws Exception if the MXBean cannot be found, or if there is a problem during invocation */ public static String dumpHeap(boolean live) throws Exception { return dumpHeap(new File("."), 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. * <p> * Creates the dump using the file name: dump_yyyyMMdd_hhmmss_SSS.hprof * <p> * @see #dumpHeap(String, boolean) * @param basedir File object for the target base directory. * @param live true id only live objects are to be dumped. * * @return the name of the dump file that was created * @throws Exception if the MXBean cannot be found, or if there is a problem during invocation */ public static String dumpHeap(File basedir, boolean live) throws Exception { SimpleDateFormat timestampFormat = new SimpleDateFormat("yyyyMMdd_hhmmss_SSS"); String stamp = timestampFormat.format(new Date()); File temp = new File(basedir,"dump_"+stamp+".hprof"); final String path = temp.getPath(); dumpHeap(path, live); return path; }
HeapDumper.dumpHeap(); break; default:
} else if (ActionNames.HEAP_DUMP.equals(e.getActionCommand())){ try { String s = HeapDumper.dumpHeap(); JOptionPane.showMessageDialog(null, "Created "+s, "HeapDump", JOptionPane.INFORMATION_MESSAGE); } catch (Exception ex) { // NOSONAR We show cause in message