package no.uio.ifi.refaktor.utils;
+import java.io.File;
import java.lang.management.ManagementFactory;
import javax.management.MBeanServer;
import com.sun.management.HotSpotDiagnosticMXBean;
/**
- * Stolen from https://blogs.oracle.com/sundararajan/entry/programmatically_dumping_heap_from_java
+ * Most of the code and the idea stolen
+ * from https://blogs.oracle.com/sundararajan/entry/programmatically_dumping_heap_from_java
*/
public class HeapDumper {
// This is the name of the HotSpot Diagnostic MBean
// initialize hotspot diagnostic MBean
initHotspotMBean();
try {
+ File file = new File(fileName);
+ if (file.exists())
+ file.delete();
hotspotMBean.dumpHeap(fileName, live);
} catch (RuntimeException re) {
throw re;