Search in sources :

Example 1 with HotSpotDiagnosticMXBean

use of com.sun.management.HotSpotDiagnosticMXBean in project jdk8u_jdk by JetBrains.

the class GetVMOption method main.

public static void main(String[] args) throws Exception {
    List<HotSpotDiagnosticMXBean> list = ManagementFactory.getPlatformMXBeans(HotSpotDiagnosticMXBean.class);
    HotSpotDiagnosticMXBean mbean = list.get(0);
    checkVMOption(mbean);
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    mbean = ManagementFactory.newPlatformMXBeanProxy(mbs, HOTSPOT_DIAGNOSTIC_MXBEAN_NAME, HotSpotDiagnosticMXBean.class);
    checkVMOption(mbean);
}
Also used : HotSpotDiagnosticMXBean(com.sun.management.HotSpotDiagnosticMXBean) MBeanServer(javax.management.MBeanServer)

Example 2 with HotSpotDiagnosticMXBean

use of com.sun.management.HotSpotDiagnosticMXBean in project jdk8u_jdk by JetBrains.

the class SetAllVMOptions method main.

public static void main(String[] args) throws Exception {
    List<HotSpotDiagnosticMXBean> list = ManagementFactory.getPlatformMXBeans(HotSpotDiagnosticMXBean.class);
    HotSpotDiagnosticMXBean mbean = list.get(0);
    setAllVMOptions(mbean);
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    mbean = ManagementFactory.newPlatformMXBeanProxy(mbs, HOTSPOT_DIAGNOSTIC_MXBEAN_NAME, HotSpotDiagnosticMXBean.class);
    setAllVMOptions(mbean);
}
Also used : HotSpotDiagnosticMXBean(com.sun.management.HotSpotDiagnosticMXBean) MBeanServer(javax.management.MBeanServer)

Example 3 with HotSpotDiagnosticMXBean

use of com.sun.management.HotSpotDiagnosticMXBean in project jgnash by ccavanaugh.

the class ConsoleDialog method dumpHeap.

private static void dumpHeap() {
    final String base = FileSystemView.getFileSystemView().getDefaultDirectory().getAbsolutePath();
    for (int i = 1; i < MAX_DUMP_FILES; i++) {
        // no more than 1000 dumps
        final File dumpFile = new File(base + FileUtils.separator + "jGnashHeapDump" + i + ".bin");
        if (!dumpFile.exists()) {
            final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
            try {
                final HotSpotDiagnosticMXBean bean = ManagementFactory.newPlatformMXBeanProxy(server, "com.sun.management:type=HotSpotDiagnostic", HotSpotDiagnosticMXBean.class);
                bean.dumpHeap(dumpFile.getAbsolutePath(), true);
            } catch (IOException e) {
                Logger.getLogger(ConsoleDialog.class.getCanonicalName()).log(Level.SEVERE, null, e);
            }
            break;
        }
    }
}
Also used : HotSpotDiagnosticMXBean(com.sun.management.HotSpotDiagnosticMXBean) IOException(java.io.IOException) File(java.io.File) MBeanServer(javax.management.MBeanServer)

Example 4 with HotSpotDiagnosticMXBean

use of com.sun.management.HotSpotDiagnosticMXBean in project jdk8u_jdk by JetBrains.

the class GetDiagnosticOptions method main.

public static void main(String[] args) throws Exception {
    List<HotSpotDiagnosticMXBean> list = ManagementFactory.getPlatformMXBeans(HotSpotDiagnosticMXBean.class);
    HotSpotDiagnosticMXBean mbean = list.get(0);
    checkDiagnosticOptions(mbean);
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    mbean = ManagementFactory.newPlatformMXBeanProxy(mbs, HOTSPOT_DIAGNOSTIC_MXBEAN_NAME, HotSpotDiagnosticMXBean.class);
    checkDiagnosticOptions(mbean);
}
Also used : HotSpotDiagnosticMXBean(com.sun.management.HotSpotDiagnosticMXBean) MBeanServer(javax.management.MBeanServer)

Example 5 with HotSpotDiagnosticMXBean

use of com.sun.management.HotSpotDiagnosticMXBean in project Lucee by lucee.

the class HeapDumper method dumpTo.

/**
 * Dumps the heap to the outputFile file in the same format as the hprof heap dump.
 * If this method is called remotely from another process, the heap dump output is written to a file named outputFile on the machine where the target VM is running. If outputFile is a relative path, it is relative to the working directory where the target VM was started.
 * @param res Resource to write the .hprof file.
 * @param live  if true dump only live objects i.e. objects that are reachable from others
 * @throws IOException
 */
public static void dumpTo(Resource res, boolean live) throws IOException {
    MBeanServer mbserver = ManagementFactory.getPlatformMBeanServer();
    HotSpotDiagnosticMXBean mxbean = ManagementFactory.newPlatformMXBeanProxy(mbserver, "com.sun.management:type=HotSpotDiagnostic", HotSpotDiagnosticMXBean.class);
    String path;
    Resource tmp = null;
    if (res instanceof FileResource)
        path = res.getAbsolutePath();
    else {
        tmp = SystemUtil.getTempFile("hprof", false);
        path = tmp.getAbsolutePath();
    }
    try {
        // it only
        mxbean.dumpHeap(path, live);
    } finally {
        if (tmp != null && tmp.exists()) {
            tmp.moveTo(res);
        }
    }
}
Also used : HotSpotDiagnosticMXBean(com.sun.management.HotSpotDiagnosticMXBean) Resource(lucee.commons.io.res.Resource) FileResource(lucee.commons.io.res.type.file.FileResource) FileResource(lucee.commons.io.res.type.file.FileResource) MBeanServer(javax.management.MBeanServer)

Aggregations

HotSpotDiagnosticMXBean (com.sun.management.HotSpotDiagnosticMXBean)5 MBeanServer (javax.management.MBeanServer)5 File (java.io.File)1 IOException (java.io.IOException)1 Resource (lucee.commons.io.res.Resource)1 FileResource (lucee.commons.io.res.type.file.FileResource)1