java.lang.management.ClassLoadingMXBean Java Examples

The following examples show how to use java.lang.management.ClassLoadingMXBean. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClassLoaderMetrics.java    From micrometer with Apache License 2.0 8 votes vote down vote up
@Override
public void bindTo(MeterRegistry registry) {
    ClassLoadingMXBean classLoadingBean = ManagementFactory.getClassLoadingMXBean();

    Gauge.builder("jvm.classes.loaded", classLoadingBean, ClassLoadingMXBean::getLoadedClassCount)
            .tags(tags)
            .description("The number of classes that are currently loaded in the Java virtual machine")
            .baseUnit(BaseUnits.CLASSES)
            .register(registry);

    FunctionCounter.builder("jvm.classes.unloaded", classLoadingBean, ClassLoadingMXBean::getUnloadedClassCount)
            .tags(tags)
            .description("The total number of classes unloaded since the Java virtual machine has started execution")
            .baseUnit(BaseUnits.CLASSES)
            .register(registry);
}
 
Example #2
Source File: FileMeter.java    From DeconvolutionLab2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void setDetail() {
	File[] roots = File.listRoots();
	int i=0;
	add(i++, new String[] { "Properties", "java.class.path", System.getProperty("java.class.path") });
	add(i++, new String[] { "Properties", "java.home", System.getProperty("java.home") });
	add(i++, new String[] { "Properties", "user.dir", System.getProperty("user.dir") });
	add(i++, new String[] { "Properties", "user.home", System.getProperty("user.home") });
	add(i++, new String[] { "Properties", "user.name", System.getProperty("user.name") });

	for (File root : roots) {
		add(i++, new String[] { "FileSystem", "Root Path", root.getAbsolutePath() });
		add(i++, new String[] { "FileSystem", "Total Space", NumFormat.bytes(root.getTotalSpace()) });
		add(i++, new String[] { "FileSystem", "Usable Space", NumFormat.bytes(root.getUsableSpace()) });
	}		
	ClassLoadingMXBean loader = ManagementFactory.getClassLoadingMXBean();
	add(i++, new String[] { "ClassLoading", "Loaded Class", "" + loader.getLoadedClassCount() });
}
 
Example #3
Source File: PlatformMBeanResourceUnitTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testClassLoadingMXBean() throws IOException {
    DescribedResource describedResource = basicResourceTest("class-loading", null);

    ClassLoadingMXBean mbean = ManagementFactory.getClassLoadingMXBean();
    boolean verbose = describedResource.resource.get("verbose").asBoolean();
    Assert.assertEquals(mbean.isVerbose(), verbose);

    ModelNode op = getOperation("write-attribute", "class-loading", null);
    op.get("name").set("verbose");
    op.get("value").set(!verbose);
    executeOp(op, false);
    Assert.assertEquals(mbean.isVerbose(), !verbose);

    // Restore
    mbean.setVerbose(verbose);
}
 
Example #4
Source File: ClassLoadingSensor.java    From swage with Apache License 2.0 5 votes vote down vote up
@Override
public void sense(final MetricContext metricContext)
{
    ClassLoadingMXBean mxBean = ManagementFactory.getClassLoadingMXBean();

    metricContext.record(CURRENT_COUNT, mxBean.getLoadedClassCount(), Unit.NONE);
    metricContext.record(TOTAL_COUNT, mxBean.getTotalLoadedClassCount(), Unit.NONE);
    metricContext.record(UNLOADED_COUNT, mxBean.getUnloadedClassCount(), Unit.NONE);
}
 
Example #5
Source File: ClassesDataProviderTest.java    From perfmon-agent with Apache License 2.0 5 votes vote down vote up
/**
 * Test of getMXBeanClass method, of class ClassesDataProvider.
 */
public void testGetMXBeanClass() throws Exception {
    System.out.println("getMXBeanClass");
    ClassesDataProvider instance = new ClassesDataProvider(new EmulatorMBeanServerConnection(), false);
    Class expResult = ClassLoadingMXBean.class;
    Class result = instance.getMXBeanClass();
    assertEquals(expResult, result);
}
 
Example #6
Source File: SysUtil.java    From game-server with MIT License 5 votes vote down vote up
/**
 * 类加载信息
 * 
 * @author JiangZhiYong
 * @QQ 359135103 2017年10月12日 下午3:39:22
 * @param spliteStr
 * @return
 */
public static String classLoadInfo(String spliteStr) {
	ClassLoadingMXBean bean = ManagementFactory.getClassLoadingMXBean();
	StringBuilder sb = new StringBuilder();
	sb.append("类加载数:   " + bean.getLoadedClassCount()).append(spliteStr);
	sb.append("类加载总数:   " + bean.getTotalLoadedClassCount()).append(spliteStr);
	sb.append("类卸载数:   " + bean.getUnloadedClassCount()).append(spliteStr);
	return sb.toString();
}
 
Example #7
Source File: SmallRyeMetricsRecorder.java    From quarkus with Apache License 2.0 5 votes vote down vote up
private void micrometerJvmClassLoaderMetrics(MetricRegistry registry) {
    // The ClassLoadingMXBean can be used in native mode, but it only returns zeroes, so there's no point in including such metrics.
    if (!ImageInfo.inImageCode()) {
        ClassLoadingMXBean classLoadingBean = ManagementFactory.getClassLoadingMXBean();

        registry.register(
                new ExtendedMetadataBuilder()
                        .withName("jvm.classes.loaded")
                        .withType(MetricType.GAUGE)
                        .withUnit("classes")
                        .withDescription("The number of classes that are currently loaded in the Java virtual machine")
                        .withOpenMetricsKeyOverride("jvm_classes_loaded_classes")
                        .build(),
                new Gauge() {
                    @Override
                    public Number getValue() {
                        return classLoadingBean.getLoadedClassCount();
                    }
                });

        registry.register(
                new ExtendedMetadataBuilder()
                        .withName("jvm.classes.unloaded")
                        .withType(MetricType.COUNTER)
                        .withUnit("classes")
                        .withDescription(
                                "The total number of classes unloaded since the Java virtual machine has started execution")
                        .withOpenMetricsKeyOverride("jvm_classes_unloaded_classes_total")
                        .build(),
                new GetCountOnlyCounter() {
                    @Override
                    public long getCount() {
                        return classLoadingBean.getUnloadedClassCount();
                    }
                });
    }
}
 
Example #8
Source File: JavaInfo.java    From haxademic with MIT License 5 votes vote down vote up
public static void printClassLoaderInfo() {
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    out.println("thread context class loader "+cl.getClass().getName());
    out.println("system class loader "+ClassLoader.getSystemClassLoader().getClass().getName());
    ClassLoadingMXBean cx = ManagementFactory.getClassLoadingMXBean();
    out.println("loaded classes count "+cx.getLoadedClassCount());
}
 
Example #9
Source File: JmxClient.java    From vjtools with Apache License 2.0 5 votes vote down vote up
public synchronized ClassLoadingMXBean getClassLoadingMXBean() throws IOException {
	if (hasPlatformMXBeans && classLoadingMBean == null) {
		classLoadingMBean = ManagementFactory.newPlatformMXBeanProxy(server,
				ManagementFactory.CLASS_LOADING_MXBEAN_NAME, ClassLoadingMXBean.class);
	}
	return classLoadingMBean;
}
 
Example #10
Source File: SystemMetrics.java    From hugegraph with Apache License 2.0 5 votes vote down vote up
private Map<String, Object> getClassLoadingMetrics() {
    Map<String, Object> metrics = new LinkedHashMap<>();
    ClassLoadingMXBean classLoadingMxBean = ManagementFactory
                                            .getClassLoadingMXBean();
    metrics.put("count", classLoadingMxBean.getLoadedClassCount());
    metrics.put("loaded", classLoadingMxBean.getTotalLoadedClassCount());
    metrics.put("unloaded", classLoadingMxBean.getUnloadedClassCount());
    return metrics;
}
 
Example #11
Source File: JmxClient.java    From vjtools with Apache License 2.0 5 votes vote down vote up
public synchronized ClassLoadingMXBean getClassLoadingMXBean() throws IOException {
	if (hasPlatformMXBeans && classLoadingMBean == null) {
		classLoadingMBean = ManagementFactory.newPlatformMXBeanProxy(server,
				ManagementFactory.CLASS_LOADING_MXBEAN_NAME, ClassLoadingMXBean.class);
	}
	return classLoadingMBean;
}
 
Example #12
Source File: MXBeanInteropTest1.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private final int doClassLoadingMXBeanTest(MBeanServerConnection mbsc) {
    int errorCount = 0 ;
    System.out.println("---- ClassLoadingMXBean") ;

    try {
        ObjectName classLoadingName =
                new ObjectName(ManagementFactory.CLASS_LOADING_MXBEAN_NAME) ;
        MBeanInfo mbInfo = mbsc.getMBeanInfo(classLoadingName);
        errorCount += checkNonEmpty(mbInfo);
        System.out.println("getMBeanInfo\t\t"
                + mbInfo);
        ClassLoadingMXBean classLoading = null;

        classLoading = JMX.newMXBeanProxy(mbsc,
                classLoadingName,
                ClassLoadingMXBean.class) ;
        System.out.println("getLoadedClassCount\t\t"
                + classLoading.getLoadedClassCount());
        System.out.println("getTotalLoadedClassCount\t\t"
                + classLoading.getTotalLoadedClassCount());
        System.out.println("getUnloadedClassCount\t\t"
                + classLoading.getUnloadedClassCount());
        System.out.println("isVerbose\t\t"
                + classLoading.isVerbose());

        System.out.println("---- OK\n") ;

    } catch (Exception e) {
        Utils.printThrowable(e, true) ;
        errorCount++ ;
        System.out.println("---- ERROR\n") ;
    }

    return errorCount ;
}
 
Example #13
Source File: JVMDiagnosticTask.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public DiagnosticsDumpElement captureDump(final boolean verbose) {
    final MemoryMXBean memory = ManagementFactory.getMemoryMXBean();
    final ClassLoadingMXBean classLoading = ManagementFactory.getClassLoadingMXBean();
    final MemoryUsage heap = memory.getHeapMemoryUsage();
    final ThreadMXBean threads = ManagementFactory.getThreadMXBean();
    final RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();

    final List<String> details = new ArrayList<>();
    final NumberFormat numberFormat = NumberFormat.getInstance();

    details.add("Total Thread Count: " + numberFormat.format(threads.getThreadCount()));
    details.add("Daemon Thread Count: " + numberFormat.format(threads.getDaemonThreadCount()));

    details.add("Max Heap: " + FormatUtils.formatDataSize(heap.getMax()));
    details.add("Heap Used: " + FormatUtils.formatDataSize(heap.getUsed()));
    details.add("Heap Committed: " + FormatUtils.formatDataSize(heap.getCommitted()));

    details.add("JVM Uptime: " + FormatUtils.formatHoursMinutesSeconds(runtime.getUptime(), TimeUnit.MILLISECONDS));

    details.add("JVM Spec Name: " + runtime.getSpecName());
    details.add("JVM Spec Vendor: " + runtime.getSpecVendor());
    details.add("JVM Spec Version: " + runtime.getSpecVersion());

    details.add("JVM Vendor: " + runtime.getVmVendor());
    details.add("JVM Version: " + runtime.getVmVersion());
    details.add("Classes Loaded: " + numberFormat.format(classLoading.getLoadedClassCount()));
    details.add("Classes Loaded Since Start: " + numberFormat.format(classLoading.getTotalLoadedClassCount()));
    details.add("Working Directory: " + new File(".").getAbsolutePath());

    return new StandardDiagnosticsDumpElement("Java Virtual Machine", details);
}
 
Example #14
Source File: ClassLoadingSampler.java    From kieker with Apache License 2.0 5 votes vote down vote up
@Override
protected IMonitoringRecord[] createNewMonitoringRecords(final long timestamp, final String hostname, final String vmName,
		final IMonitoringController monitoringCtr) {
	if (!monitoringCtr.isProbeActivated(SignatureFactory.createJVMClassLoadSignature())) {
		return new IMonitoringRecord[] {};
	}

	final ClassLoadingMXBean classLoadingBean = ManagementFactory.getClassLoadingMXBean();
	return new IMonitoringRecord[] { new ClassLoadingRecord(timestamp, hostname, vmName, classLoadingBean.getTotalLoadedClassCount(),
			classLoadingBean.getLoadedClassCount(), classLoadingBean.getUnloadedClassCount()), };
}
 
Example #15
Source File: ClassProfiler.java    From openjdk-systemtest with Apache License 2.0 5 votes vote down vote up
private void recordClassStats(RuntimeMXBean rb, ClassLoadingMXBean cb) {
	// Print out time in 2 d.p.
	DecimalFormat df = new DecimalFormat("#0.00"); 
	// Write stats to file
	this.csv.println(df.format(rb.getUptime() / 1000) + "," + cb.getLoadedClassCount() + ","
			+ cb.getTotalLoadedClassCount() + "," + cb.getUnloadedClassCount());
}
 
Example #16
Source File: Test.java    From ClusterDeviceControlPlatform with MIT License 5 votes vote down vote up
private static void printClassLoadingInfo() {
    ClassLoadingMXBean classLoad = ManagementFactory.getClassLoadingMXBean();
    System.out.println("已加载类总数:" + classLoad.getTotalLoadedClassCount());
    System.out.println("已加载当前类:" + classLoad.getLoadedClassCount());
    System.out.println("已卸载类总数:" + classLoad.getUnloadedClassCount());

}
 
Example #17
Source File: Test.java    From ClusterDeviceControlPlatform with MIT License 5 votes vote down vote up
private static void printClassLoadingInfo() {
    ClassLoadingMXBean classLoad = ManagementFactory.getClassLoadingMXBean();
    System.out.println("已加载类总数:" + classLoad.getTotalLoadedClassCount());
    System.out.println("已加载当前类:" + classLoad.getLoadedClassCount());
    System.out.println("已卸载类总数:" + classLoad.getUnloadedClassCount());

}
 
Example #18
Source File: JMServer.java    From jmonitor with GNU General Public License v2.0 5 votes vote down vote up
@HttpMapping(url = "/loadRuntimeInfo")
public JSONObject doLoadRuntimeInfo(Map<String, Object> param) {
    try {
        String app = ((HttpServletRequest) param.get(JMDispatcher.REQ)).getParameter("app");
        RuntimeMXBean mBean = JMConnManager.getRuntimeMBean(app);
        ClassLoadingMXBean cBean = JMConnManager.getClassMbean(app);
        Map<String, String> props = mBean.getSystemProperties();
        DateFormat format = DateFormat.getInstance();
        List<String> input = mBean.getInputArguments();
        Date date = new Date(mBean.getStartTime());

        TreeMap<String, Object> data = new TreeMap<String, Object>();

        data.put("apppid", mBean.getName());
        data.put("startparam", input.toString());
        data.put("starttime", format.format(date));
        data.put("classLoadedNow", cBean.getLoadedClassCount());
        data.put("classUnloadedAll", cBean.getUnloadedClassCount());
        data.put("classLoadedAll", cBean.getTotalLoadedClassCount());
        data.putAll(props);

        JSONObject json = new JSONObject(true);
        json.putAll(data);
        return json;
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
Example #19
Source File: MXBeanInteropTest1.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private final int doClassLoadingMXBeanTest(MBeanServerConnection mbsc) {
    int errorCount = 0 ;
    System.out.println("---- ClassLoadingMXBean") ;

    try {
        ObjectName classLoadingName =
                new ObjectName(ManagementFactory.CLASS_LOADING_MXBEAN_NAME) ;
        MBeanInfo mbInfo = mbsc.getMBeanInfo(classLoadingName);
        errorCount += checkNonEmpty(mbInfo);
        System.out.println("getMBeanInfo\t\t"
                + mbInfo);
        ClassLoadingMXBean classLoading = null;

        classLoading = JMX.newMXBeanProxy(mbsc,
                classLoadingName,
                ClassLoadingMXBean.class) ;
        System.out.println("getLoadedClassCount\t\t"
                + classLoading.getLoadedClassCount());
        System.out.println("getTotalLoadedClassCount\t\t"
                + classLoading.getTotalLoadedClassCount());
        System.out.println("getUnloadedClassCount\t\t"
                + classLoading.getUnloadedClassCount());
        System.out.println("isVerbose\t\t"
                + classLoading.isVerbose());

        System.out.println("---- OK\n") ;

    } catch (Exception e) {
        Utils.printThrowable(e, true) ;
        errorCount++ ;
        System.out.println("---- ERROR\n") ;
    }

    return errorCount ;
}
 
Example #20
Source File: MXBeanInteropTest1.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private final int doClassLoadingMXBeanTest(MBeanServerConnection mbsc) {
    int errorCount = 0 ;
    System.out.println("---- ClassLoadingMXBean") ;

    try {
        ObjectName classLoadingName =
                new ObjectName(ManagementFactory.CLASS_LOADING_MXBEAN_NAME) ;
        MBeanInfo mbInfo = mbsc.getMBeanInfo(classLoadingName);
        errorCount += checkNonEmpty(mbInfo);
        System.out.println("getMBeanInfo\t\t"
                + mbInfo);
        ClassLoadingMXBean classLoading = null;

        classLoading = JMX.newMXBeanProxy(mbsc,
                classLoadingName,
                ClassLoadingMXBean.class) ;
        System.out.println("getLoadedClassCount\t\t"
                + classLoading.getLoadedClassCount());
        System.out.println("getTotalLoadedClassCount\t\t"
                + classLoading.getTotalLoadedClassCount());
        System.out.println("getUnloadedClassCount\t\t"
                + classLoading.getUnloadedClassCount());
        System.out.println("isVerbose\t\t"
                + classLoading.isVerbose());

        System.out.println("---- OK\n") ;

    } catch (Exception e) {
        Utils.printThrowable(e, true) ;
        errorCount++ ;
        System.out.println("---- ERROR\n") ;
    }

    return errorCount ;
}
 
Example #21
Source File: ProxyClient.java    From jvmtop with GNU General Public License v2.0 5 votes vote down vote up
public synchronized ClassLoadingMXBean getClassLoadingMXBean() throws IOException {
    if (hasPlatformMXBeans && classLoadingMBean == null) {
        classLoadingMBean =
            newPlatformMXBeanProxy(server, CLASS_LOADING_MXBEAN_NAME,
                                   ClassLoadingMXBean.class);
    }
    return classLoadingMBean;
}
 
Example #22
Source File: OperatingSystemInfoUtil.java    From Deta_Cache with Apache License 2.0 5 votes vote down vote up
/**
	 * Java ������������ϵͳ
	 */
	public static Map<String, String> showClassLoading(){
		Map<String, String> map = new HashMap<>();
		ClassLoadingMXBean cl = ManagementFactory.getClassLoadingMXBean();
		map.put("TotalLoadedClassCount: ", "" +cl.getTotalLoadedClassCount());
		map.put("LoadedClassCount", "" + cl.getLoadedClassCount());
		map.put("UnloadedClassCount:" , "" + cl.getTotalLoadedClassCount());	
		return map;	
//		System.out.println("TotalLoadedClassCount: " + cl.getTotalLoadedClassCount());
//		System.out.println("LoadedClassCount" + cl.getLoadedClassCount());
//		System.out.println("UnloadedClassCount:" + cl.getUnloadedClassCount());
	}
 
Example #23
Source File: MXBeanInteropTest1.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private final int doClassLoadingMXBeanTest(MBeanServerConnection mbsc) {
    int errorCount = 0 ;
    System.out.println("---- ClassLoadingMXBean") ;

    try {
        ObjectName classLoadingName =
                new ObjectName(ManagementFactory.CLASS_LOADING_MXBEAN_NAME) ;
        MBeanInfo mbInfo = mbsc.getMBeanInfo(classLoadingName);
        errorCount += checkNonEmpty(mbInfo);
        System.out.println("getMBeanInfo\t\t"
                + mbInfo);
        ClassLoadingMXBean classLoading = null;

        classLoading = JMX.newMXBeanProxy(mbsc,
                classLoadingName,
                ClassLoadingMXBean.class) ;
        System.out.println("getLoadedClassCount\t\t"
                + classLoading.getLoadedClassCount());
        System.out.println("getTotalLoadedClassCount\t\t"
                + classLoading.getTotalLoadedClassCount());
        System.out.println("getUnloadedClassCount\t\t"
                + classLoading.getUnloadedClassCount());
        System.out.println("isVerbose\t\t"
                + classLoading.isVerbose());

        System.out.println("---- OK\n") ;

    } catch (Exception e) {
        Utils.printThrowable(e, true) ;
        errorCount++ ;
        System.out.println("---- ERROR\n") ;
    }

    return errorCount ;
}
 
Example #24
Source File: ClassloadMetrics.java    From watcher with Apache License 2.0 5 votes vote down vote up
public Object doMonitor(Map<String, Object> params) {
	Map<String, Object> map = Maps.newHashMap();
	ClassLoadingMXBean mxBean = ManagementFactory.getClassLoadingMXBean();
	map.put("totalLoadedClassCount", mxBean.getTotalLoadedClassCount());
	map.put("loadedClassCount", mxBean.getLoadedClassCount());
	map.put("unloadedClassCount", mxBean.getUnloadedClassCount());
	return map;
}
 
Example #25
Source File: JVMStateCapHandler.java    From uavstack with Apache License 2.0 5 votes vote down vote up
private void readClassLoadUsage(MonitorElementInstance instance) {

        ClassLoadingMXBean clmb = ManagementFactory.getClassLoadingMXBean();

        instance.setValue("class_total", clmb.getTotalLoadedClassCount());
        instance.setValue("class_load", clmb.getLoadedClassCount());
        instance.setValue("class_unload", clmb.getUnloadedClassCount());
    }
 
Example #26
Source File: ClassLoaderUtilsTest.java    From confucius-commons with Apache License 2.0 5 votes vote down vote up
@Test
public void testClassLoadingMXBean() {
    ClassLoadingMXBean classLoadingMXBean = ClassLoaderUtils.classLoadingMXBean;
    Assert.assertEquals(classLoadingMXBean.getTotalLoadedClassCount(), ClassLoaderUtils.getTotalLoadedClassCount());
    Assert.assertEquals(classLoadingMXBean.getLoadedClassCount(), ClassLoaderUtils.getLoadedClassCount());
    Assert.assertEquals(classLoadingMXBean.getUnloadedClassCount(), ClassLoaderUtils.getUnloadedClassCount());
    Assert.assertEquals(classLoadingMXBean.isVerbose(), ClassLoaderUtils.isVerbose());

    ClassLoaderUtils.setVerbose(true);
    Assert.assertTrue(ClassLoaderUtils.isVerbose());
}
 
Example #27
Source File: ProxyClient.java    From jmxmon with Apache License 2.0 5 votes vote down vote up
public synchronized ClassLoadingMXBean getClassLoadingMXBean() throws IOException {
    if (hasPlatformMXBeans && classLoadingMBean == null) {
        classLoadingMBean =
            newPlatformMXBeanProxy(server, CLASS_LOADING_MXBEAN_NAME,
                                   ClassLoadingMXBean.class);
    }
    return classLoadingMBean;
}
 
Example #28
Source File: MonitoredDataImpl.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
MonitoredDataImpl(JmxSupport jmxSupport,JvmMXBeans jmxModel) {
  this(jmxSupport);
  RuntimeMXBean runtimeBean = jmxModel.getRuntimeMXBean();
  upTime = runtimeBean.getUptime();
  ClassLoadingMXBean classBean = jmxModel.getClassLoadingMXBean();
  ThreadMXBean threadBean = jmxModel.getThreadMXBean();
  MemoryUsage mem = jmxModel.getMemoryMXBean().getHeapMemoryUsage();
  MemoryPoolMXBean permBean = jmxSupport.getPermGenPool();
  unloadedClasses = classBean.getUnloadedClassCount();
  loadedClasses = classBean.getLoadedClassCount() + unloadedClasses;
  sharedLoadedClasses = 0;
  sharedUnloadedClasses = 0;
  threadsDaemon = threadBean.getDaemonThreadCount();
  threadsLive = threadBean.getThreadCount();
  threadsLivePeak = threadBean.getPeakThreadCount();
  threadsStarted = threadBean.getTotalStartedThreadCount();
  applicationTime = 0;
  genCapacity = new long[2];
  genUsed = new long[2];
  genMaxCapacity = new long[2];
  genCapacity[0] = mem.getCommitted();
  genUsed[0] = mem.getUsed();
  genMaxCapacity[0] = mem.getMax();
  if (permBean != null) {
      MemoryUsage perm = permBean.getUsage();
      genCapacity[1] = perm.getCommitted();
      genUsed[1] = perm.getUsed();
      genMaxCapacity[1] = perm.getMax();
  }
}
 
Example #29
Source File: JvmMXBeansFactory.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns an MXBean proxy for the class loading system of the JVM.
 */
public synchronized ClassLoadingMXBean getClassLoadingMXBean() {
    if (mbsc != null && classLoadingMXBean == null) {
        classLoadingMXBean = getMXBean(CLASS_LOADING_MXBEAN_NAME, ClassLoadingMXBean.class);
    }
    return classLoadingMXBean;
}
 
Example #30
Source File: MXBeanInteropTest1.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private final int doClassLoadingMXBeanTest(MBeanServerConnection mbsc) {
    int errorCount = 0 ;
    System.out.println("---- ClassLoadingMXBean") ;

    try {
        ObjectName classLoadingName =
                new ObjectName(ManagementFactory.CLASS_LOADING_MXBEAN_NAME) ;
        MBeanInfo mbInfo = mbsc.getMBeanInfo(classLoadingName);
        errorCount += checkNonEmpty(mbInfo);
        System.out.println("getMBeanInfo\t\t"
                + mbInfo);
        ClassLoadingMXBean classLoading = null;

        classLoading = JMX.newMXBeanProxy(mbsc,
                classLoadingName,
                ClassLoadingMXBean.class) ;
        System.out.println("getLoadedClassCount\t\t"
                + classLoading.getLoadedClassCount());
        System.out.println("getTotalLoadedClassCount\t\t"
                + classLoading.getTotalLoadedClassCount());
        System.out.println("getUnloadedClassCount\t\t"
                + classLoading.getUnloadedClassCount());
        System.out.println("isVerbose\t\t"
                + classLoading.isVerbose());

        System.out.println("---- OK\n") ;

    } catch (Exception e) {
        Utils.printThrowable(e, true) ;
        errorCount++ ;
        System.out.println("---- ERROR\n") ;
    }

    return errorCount ;
}