当前位置: 首页>>代码示例>>Java>>正文


Java ManagementFactory.getClassLoadingMXBean方法代码示例

本文整理汇总了Java中java.lang.management.ManagementFactory.getClassLoadingMXBean方法的典型用法代码示例。如果您正苦于以下问题:Java ManagementFactory.getClassLoadingMXBean方法的具体用法?Java ManagementFactory.getClassLoadingMXBean怎么用?Java ManagementFactory.getClassLoadingMXBean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.management.ManagementFactory的用法示例。


在下文中一共展示了ManagementFactory.getClassLoadingMXBean方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sense

import java.lang.management.ManagementFactory; //导入方法依赖的package包/类
@Override
public void sense(final MetricRecorder.Context 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);
}
 
开发者ID:awslabs,项目名称:swage,代码行数:10,代码来源:ClassLoadingSensor.java

示例2: bindTo

import java.lang.management.ManagementFactory; //导入方法依赖的package包/类
@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")
        .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")
        .register(registry);
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:15,代码来源:ClassLoaderMetrics.java

示例3: readClassLoadUsage

import java.lang.management.ManagementFactory; //导入方法依赖的package包/类
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());
    }
 
开发者ID:uavorg,项目名称:uavstack,代码行数:9,代码来源:JVMStateCapHandler.java

示例4: logParams

import java.lang.management.ManagementFactory; //导入方法依赖的package包/类
private String logParams() {
        StringBuilder sb = new StringBuilder(500);
        sb.append("Diagnostic information\n");
        try {
            RuntimeMXBean         rmBean     = ManagementFactory.getRuntimeMXBean();
            CompilationMXBean     cmpMBean   = ManagementFactory.getCompilationMXBean();
//            ThreadMXBean          tmBean     = ManagementFactory.getThreadMXBean();
            MemoryMXBean          memoryBean = ManagementFactory.getMemoryMXBean();
            ClassLoadingMXBean    clMBean    = ManagementFactory.getClassLoadingMXBean();

//            MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
//            ObjectName hsDiag = new ObjectName("com.sun.management:name=HotSpotDiagnostic");
//            com.sun.management.OperatingSystemMXBean sunOSMBean  =
//               ManagementFactory.getSunOperatingSystemMXBean();

//            Map<String, String> props = new TreeMap<String, String>(rmBean.getSystemProperties());
//            System.out.println("System properties");
//            for (Map.Entry<String, String> entry: props.entrySet()) {
//                System.out.println("Property: "+entry.getKey()+" Value: "+entry.getValue());
//            }
            sb.append("Input arguments:");
            for (String s: rmBean.getInputArguments()) {
                sb.append("\n\t").append(s);
            }
            
            if (cmpMBean != null) {
                sb.append("\nCompiler: "+cmpMBean.getName()).append('\n');
            }
            
            // Memory
            MemoryUsage usage = memoryBean.getHeapMemoryUsage();
            logMemoryUsage(sb, usage, "Heap memory");
            usage = memoryBean.getNonHeapMemoryUsage();
            logMemoryUsage(sb, usage, "Non heap memory");
            for (GarbageCollectorMXBean gcMBean: ManagementFactory.getGarbageCollectorMXBeans()) {
                sb.append("Garbage collector: ").append(gcMBean.getName())
                        .append(" (Collections=").append(gcMBean.getCollectionCount())
                        .append(" Total time spent=").append(formatTime(gcMBean.getCollectionTime()))
                        .append(")\n");
            }
            
            // classes
            int clsLoaded;
            long clsTotal, clsUnloaded;
            clsLoaded = clMBean.getLoadedClassCount();
            clsTotal = clMBean.getTotalLoadedClassCount();
            clsUnloaded = clMBean.getUnloadedClassCount();
            sb.append("Classes: loaded=").append(clsLoaded)
                    .append(" total loaded=").append(clsTotal)
                    .append(" unloaded ").append(clsUnloaded).append('\n');

//        } catch (MalformedObjectNameException ex) {
//            Logger.getLogger("global").log(Level.WARNING, null, ex);
        } catch (NullPointerException ex) {
            LOG.log(Level.WARNING, null, ex);
        }
        return sb.toString();
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:59,代码来源:DiagnosticTask.java

示例5: initialize

import java.lang.management.ManagementFactory; //导入方法依赖的package包/类
/** Should be called at earliest possible time */
public static void initialize() {
    classLoadingBean = ManagementFactory.getClassLoadingMXBean();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:Classes.java

示例6: setFactory

import java.lang.management.ManagementFactory; //导入方法依赖的package包/类
private void setFactory() {
 mxbean = ManagementFactory.getRuntimeMXBean();
 // 以下是取得虚拟机的属性
 System.out.println("===============虚拟机信息===================");
 System.out.println("虚拟机提供商:" + mxbean.getVmVendor());
 System.out.println("虚拟机名称:" + mxbean.getVmName());
 System.out.println("当前类路径:" + mxbean.getClassPath());
 System.out.println("进程号@机器:" + mxbean.getName());
 System.out.println("运行时间(毫秒):" + mxbean.getUptime());

 // 类管理接口
 System.out.println("===============类加载信息===================");
 ClassLoadingMXBean aClassLoadingMXBean = ManagementFactory
   .getClassLoadingMXBean();
 System.out.println("已加载类总数:"
   + aClassLoadingMXBean.getLoadedClassCount());
 System.out.println("Verbose状态:" + aClassLoadingMXBean.isVerbose());

 // 内存管理接口
 System.out.println("===============内存信息=====================");
 MemoryMXBean aMemoryMXBean = ManagementFactory.getMemoryMXBean();
 System.out.println("终止被挂起数:"
   + aMemoryMXBean.getObjectPendingFinalizationCount());// 返回其终止被挂起的对象的近似数目
 // 返回 Java 虚拟机使用的非堆内存的当前使用量
 MemoryUsage aMemoryUsage = aMemoryMXBean.getNonHeapMemoryUsage(); // 虚拟机启动时从系统得到的内存(以字节为单位)
 System.out.println("虚拟机启动时从系统得到的内存:" + aMemoryUsage.getInit()); // 表示当前已经使用的内存量(以字节为单位)
 System.out.println("当前已经使用的内存量:" + aMemoryUsage.getUsed()); // 表示保证可以由
 // Java
 // 虚拟机使用的内存量(以字节为单位)

 System.out.println("虚拟机使用的内存量:" + aMemoryUsage.getCommitted()); // 表示可以用于内存管理的最大内存量(以字节为单位)
 System.out.println("内存管理的初始内存量:" + aMemoryUsage.getInit());
 System.out.println("内存管理的最大内存量:" + aMemoryUsage.getMax());
 System.out.println("总体描述:" + aMemoryUsage.toString());
 
 java.util.List<GarbageCollectorMXBean> aGCMXBeans = ManagementFactory.getGarbageCollectorMXBeans();
 GarbageCollectorMXBean aGCMXBean = aGCMXBeans.get(0);
 System.out.println("===============GC信息=====================");
 System.out.println("收集总数:" + aGCMXBean.getCollectionCount());
 System.out.println("收集时间:" + aGCMXBean.getCollectionTime());
 System.out.println("内存管理器有效:" + aGCMXBean.isValid());
 System.out.println("内存池名:" + aGCMXBean.getMemoryPoolNames()[0]);
 System.out.println("内存池名:" + aGCMXBean.getMemoryPoolNames()[1]);
 
 
 System.out.println("*****************End**********************");
}
 
开发者ID:juebanlin,项目名称:util4j,代码行数:48,代码来源:TestJmx.java

示例7: getClassLoadingMXBean

import java.lang.management.ManagementFactory; //导入方法依赖的package包/类
static ClassLoadingMXBean getClassLoadingMXBean() {
    return ManagementFactory.getClassLoadingMXBean();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:JvmClassLoadingImpl.java

示例8: main

import java.lang.management.ManagementFactory; //导入方法依赖的package包/类
public static void main(String[] args) {
    ClassLoadingMXBean classLoadingMXBean = ManagementFactory.getClassLoadingMXBean();
    System.out.println("Loaded classes: " + classLoadingMXBean.getLoadedClassCount());
    System.out.println("Total loaded classes: " + classLoadingMXBean.getTotalLoadedClassCount());
    System.out.println("Unloaded classes: " + classLoadingMXBean.getUnloadedClassCount());
}
 
开发者ID:kslisenko,项目名称:java-performance,代码行数:7,代码来源:ClassLoading.java


注:本文中的java.lang.management.ManagementFactory.getClassLoadingMXBean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。