/** * 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 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