core/src/main/java/com/orientechnologies/common/util/HeapDumper.java
public static void dumpHeap(String fileName, boolean live) {
    try {
      MBeanServer server = ManagementFactory.getPlatformMBeanServer();
      server.invoke(new ObjectName(HOTSPOT_BEAN_NAME),
          "dumpHeap",
          new Object[]{fileName, live},
          new String[]{String.class.getName(), Boolean.TYPE.getName()}
      );
    } catch (RuntimeException re) {
      throw re;
    } catch (Exception exp) {
      throw new RuntimeException(exp);
    }
  }
public static void dumpHeap(String fileName, boolean live) {
    try {
      MBeanServer server = ManagementFactory.getPlatformMBeanServer();
      server.invoke(new ObjectName(HOTSPOT_BEAN_NAME),
          "dumpHeap",
          new Object[]{fileName, live},
          new String[]{String.class.getName(), Boolean.TYPE.getName()}
      );
    } catch (RuntimeException re) {
      throw re;
    } catch (Exception exp) {
      throw new RuntimeException(exp);
    }
  }
Invoke {@code dumpHeap} operation on {@code com.sun.management:type=HotSpotDiagnostic} mbean.