Package com.sun.management

Examples of com.sun.management.HotSpotDiagnosticMXBean


   * get the hotspot diagnostic MBean from the ManagementFactory.
   */
  private static HotSpotDiagnosticMXBean getHotspotMBean() {
    try {
      MBeanServer server = ManagementFactory.getPlatformMBeanServer();
      HotSpotDiagnosticMXBean bean = ManagementFactory.newPlatformMXBeanProxy(server, HOTSPOT_BEAN_NAME,
          HotSpotDiagnosticMXBean.class);
      return bean;
    } catch (RuntimeException re) {
      throw re;
    } catch (Exception exp) {
View Full Code Here


    public void createDump(DumpDestination destination) throws Exception {
        FileInputStream in = null;
        OutputStream out = null;
        try {
            MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
            HotSpotDiagnosticMXBean diagnosticMXBean = ManagementFactory.newPlatformMXBeanProxy(mBeanServer,
                    "com.sun.management:type=HotSpotDiagnostic", HotSpotDiagnosticMXBean.class);
            diagnosticMXBean.dumpHeap("heapdump.txt", false);
            // copy the dump in the destination
            File heapDumpFile = new File("heapdump.txt");
            in = new FileInputStream(heapDumpFile);
            out = destination.add("heapdump.txt");
            byte[] buffer = new byte[2048];
View Full Code Here

        File heapDumpFile = null;
        FileInputStream in = null;
        OutputStream out = null;
        try {
            MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
            HotSpotDiagnosticMXBean diagnosticMXBean = ManagementFactory.newPlatformMXBeanProxy(mBeanServer,
                    "com.sun.management:type=HotSpotDiagnostic", HotSpotDiagnosticMXBean.class);
            heapDumpFile = File.createTempFile("heapdump", ".txt");
            heapDumpFile.delete();
            diagnosticMXBean.dumpHeap(heapDumpFile.getAbsolutePath(), false);
            // copy the dump in the destination
            in = new FileInputStream(heapDumpFile);
            out = destination.add("heapdump.txt");
            byte[] buffer = new byte[2048];
            int l;
View Full Code Here

    public void dumpHeapSun(String heapName){
        final MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean();
        final OperatingSystemMXBean osBean = ManagementFactory.getOperatingSystemMXBean();
        final MBeanServer platformBean = ManagementFactory.getPlatformMBeanServer();
       
        HotSpotDiagnosticMXBean bean = null;
       
        try {
            bean = ManagementFactory.newPlatformMXBeanProxy(platformBean,
                                                            "com.sun.management:type=HotSpotDiagnostic",
                                                            HotSpotDiagnosticMXBean.class);
            deleteFile(heapName);
            bean.dumpHeap(heapName, false);
        } catch(Exception ex){
            ex.printStackTrace();
        }
    }
View Full Code Here

    public void createDump(DumpDestination destination) throws Exception {
        FileInputStream in = null;
        OutputStream out = null;
        try {
            MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
            HotSpotDiagnosticMXBean diagnosticMXBean = ManagementFactory.newPlatformMXBeanProxy(mBeanServer,
                    "com.sun.management:type=HotSpotDiagnostic", HotSpotDiagnosticMXBean.class);
            diagnosticMXBean.dumpHeap("heapdump.txt", false);
            // copy the dump in the destination
            File heapDumpFile = new File("heapdump.txt");
            in = new FileInputStream(heapDumpFile);
            out = destination.add("heapdump.txt");
            byte[] buffer = new byte[2048];
View Full Code Here

  private static final String HOTSPOT_BEAN_NAME = "com.sun.management:type=HotSpotDiagnostic";

  private static void checkGcLogging() throws IOException {
    MBeanServer server = ManagementFactory.getPlatformMBeanServer();
    HotSpotDiagnosticMXBean bean = ManagementFactory.newPlatformMXBeanProxy(
        server, HOTSPOT_BEAN_NAME, HotSpotDiagnosticMXBean.class);
    if (!bean.getVMOption("PrintGC").getValue().equals(Boolean.TRUE.toString())) {
      System.err.println("This is only useful if you run with -XX:+PrintGC");
      System.exit(1);
    }
  }
View Full Code Here

   * @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);
      }
View Full Code Here

    // get the hotspot diagnostic MBean from the
    // platform MBean server
    private static HotSpotDiagnosticMXBean getHotspotMBean() {
        try {
            MBeanServer server = ManagementFactory.getPlatformMBeanServer();
            HotSpotDiagnosticMXBean bean = ManagementFactory.newPlatformMXBeanProxy(server, HOTSPOT_BEAN_NAME, HotSpotDiagnosticMXBean.class);
            return bean;
        } catch (RuntimeException re) {
            throw re;
        } catch (Exception exp) {
            throw new RuntimeException(exp);
View Full Code Here

    private static String BAD_OPTION = "BadOption";
    private static String HOTSPOT_DIAGNOSTIC_MXBEAN_NAME =
        "com.sun.management:type=HotSpotDiagnostic";

    public static void main(String[] args) throws Exception {
        HotSpotDiagnosticMXBean mbean =
            sun.management.ManagementFactory.getDiagnosticMXBean();
        checkVMOption(mbean);

        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        mbean = ManagementFactory.newPlatformMXBeanProxy(mbs,
View Full Code Here

import com.sun.management.HotSpotDiagnosticMXBean;

public class DumpHeap {
    public static void main(String[] argv) throws Exception {
         MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
         HotSpotDiagnosticMXBean dm = sun.management.ManagementFactory.getDiagnosticMXBean();
         System.out.println("Dumping to file: " + argv[0] + " ....");
         dm.dumpHeap(argv[0], true);
    }
View Full Code Here

TOP

Related Classes of com.sun.management.HotSpotDiagnosticMXBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.