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


Java MemoryManagerMXBean类代码示例

本文整理汇总了Java中java.lang.management.MemoryManagerMXBean的典型用法代码示例。如果您正苦于以下问题:Java MemoryManagerMXBean类的具体用法?Java MemoryManagerMXBean怎么用?Java MemoryManagerMXBean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getMemoryPools

import java.lang.management.MemoryManagerMXBean; //导入依赖的package包/类
/**
 * Get the list of memory pool associated with the
 * given MemoryManagerMXBean.
 **/
protected String[] getMemoryPools(Object userData,
                              MemoryManagerMXBean mmm, long mmarc) {
    final String listTag =
        "JvmMemManager." + mmarc + ".getMemoryPools";

    String[] result=null;
    if (userData instanceof Map) {
        result = (String[])((Map)userData).get(listTag);
        if (result != null) return result;
    }

    if (mmm!=null) {
        result = mmm.getMemoryPoolNames();
    }
    if ((result!=null)&&(userData instanceof Map)) {
        Map<Object, Object> map = Util.cast(userData);
        map.put(listTag,result);
    }

    return result;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:JvmMemMgrPoolRelTableMetaImpl.java

示例2: updateTreeMap

import java.lang.management.MemoryManagerMXBean; //导入依赖的package包/类
protected void updateTreeMap(TreeMap<SnmpOid, Object> table, Object userData,
                             SnmpTableHandler mmHandler,
                             SnmpTableHandler mpHandler,
                             Map<String, SnmpOid> poolIndexMap) {
    if (mmHandler instanceof SnmpCachedData) {
        updateTreeMap(table,userData,(SnmpCachedData)mmHandler,
                      mpHandler,poolIndexMap);
        return;
    }

    SnmpOid mmIndex=null;
    while ((mmIndex = mmHandler.getNext(mmIndex))!=null) {
        final MemoryManagerMXBean mmm =
            (MemoryManagerMXBean)mmHandler.getData(mmIndex);
        if (mmm == null) continue;
        updateTreeMap(table,userData,mmm,mmIndex,poolIndexMap);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:JvmMemMgrPoolRelTableMetaImpl.java

示例3: runTest

import java.lang.management.MemoryManagerMXBean; //导入依赖的package包/类
protected void runTest() {
    List<MemoryManagerMXBean> beans
            = ManagementFactory.getMemoryManagerMXBeans();
    Optional<MemoryManagerMXBean> any = beans
            .stream()
            .filter(bean -> CC_MANAGER.equals(bean.getName()))
            .findAny();
    Asserts.assertTrue(any.isPresent(), "Bean not found: " + CC_MANAGER);
    MemoryManagerMXBean ccManager = any.get();
    Asserts.assertNotNull(ccManager, "Found null for " + CC_MANAGER);
    String names[] = ccManager.getMemoryPoolNames();
    for (String name : names) {
        counters.put(name, counters.containsKey(name)
                ? counters.get(name) + 1 : 1);
    }
    for (BlobType btype : BlobType.getAvailable()) {
        Asserts.assertEQ(counters.get(btype.getMemoryPool().getName()), 1,
                "Found unexpected amount of beans for pool "
                + btype.getMemoryPool().getName());
    }
    Asserts.assertEQ(BlobType.getAvailable().size(),
            counters.keySet().size(), "Unexpected amount of bean names");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:MemoryPoolsPresenceTest.java

示例4: updateTreeMap

import java.lang.management.MemoryManagerMXBean; //导入依赖的package包/类
protected void updateTreeMap(TreeMap<SnmpOid, Object> table, Object userData,
                             SnmpTableHandler mmHandler,
                             SnmpTableHandler mpHandler,
                             Map poolIndexMap) {
    if (mmHandler instanceof SnmpCachedData) {
        updateTreeMap(table,userData,(SnmpCachedData)mmHandler,
                      mpHandler,poolIndexMap);
        return;
    }

    SnmpOid mmIndex=null;
    while ((mmIndex = mmHandler.getNext(mmIndex))!=null) {
        final MemoryManagerMXBean mmm =
            (MemoryManagerMXBean)mmHandler.getData(mmIndex);
        if (mmm == null) continue;
        updateTreeMap(table,userData,mmm,mmIndex,poolIndexMap);
    }
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:19,代码来源:JvmMemMgrPoolRelTableMetaImpl.java

示例5: getMemoryManagerNames

import java.lang.management.MemoryManagerMXBean; //导入依赖的package包/类
public String[] getMemoryManagerNames() {
    /* get the memory managers and check which of them manage this pool */
    Iterator<MemoryManagerMXBean> iter = memBean.getMemoryManagerMXBeans()
            .iterator();
    List<String> result = new LinkedList<String>();
    while (iter.hasNext()) {
        MemoryManagerMXBean bean = iter.next();
        String[] managedPools = bean.getMemoryPoolNames();
        for (int i = 0; i < managedPools.length; i++) {
            if (managedPools[i].equals(name)) {
                result.add(bean.getName());
                break;
            }
        }
    }
    return result.toArray(new String[0]);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:18,代码来源:MemoryPoolMXBeanImpl.java

示例6: addMemoryManagerBeanInfo

import java.lang.management.MemoryManagerMXBean; //导入依赖的package包/类
/**
 * Creates the metadata for the
 * {@link java.lang.management.MemoryManagerMXBean}. For this type of
 * platform bean the metadata covers :
 * <ul>
 * <li>3 attribute
 * <li>0 constructors
 * <li>0 operations
 * <li>0 notifications
 * </ul>
 * 
 * @param map
 */
private static void addMemoryManagerBeanInfo(HashMap<String, MBeanInfo> map) {
    // Attributes
    MBeanAttributeInfo[] attributes = new MBeanAttributeInfo[3];
    attributes[0] = new MBeanAttributeInfo("MemoryPoolNames",
            "[Ljava.lang.String;", "MemoryPoolNames", true, false, false);
    attributes[1] = new MBeanAttributeInfo("Name", String.class.getName(),
            "Name", true, false, false);
    attributes[2] = new MBeanAttributeInfo("Valid", Boolean.TYPE.getName(),
            "Valid", true, false, true);

    map.put(MemoryManagerMXBean.class.getName(), new MBeanInfo(
            MemoryManagerMXBeanImpl.class.getName(),
            MemoryManagerMXBeanImpl.class.getName(), attributes, null,
            null, null));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:29,代码来源:ManagementUtils.java

示例7: getMemoryManagerNames

import java.lang.management.MemoryManagerMXBean; //导入依赖的package包/类
public String[] getMemoryManagerNames() {
    MemoryManagerMXBean[] mgrs = getMemoryManagers();

    String[] names = new String[mgrs.length];
    for (int i = 0; i < mgrs.length; i++) {
        names[i] = mgrs[i].getName();
    }
    return names;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:MemoryPoolImpl.java

示例8: verifyThatMetaspaceMemoryManagerExists

import java.lang.management.MemoryManagerMXBean; //导入依赖的package包/类
private static void verifyThatMetaspaceMemoryManagerExists() {
    List<MemoryManagerMXBean> managers = ManagementFactory.getMemoryManagerMXBeans();
    for (MemoryManagerMXBean manager : managers) {
        if (manager.getName().equals("Metaspace Manager")) {
            return;
        }
    }

    throw new RuntimeException("Expected to find a metaspace memory manager");
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:11,代码来源:TestMetaspaceMemoryPool.java

示例9: doMemoryManagerMXBeanTest

import java.lang.management.MemoryManagerMXBean; //导入依赖的package包/类
private final int doMemoryManagerMXBeanTest(MBeanServerConnection mbsc) {
    int errorCount = 0 ;
    System.out.println("---- MemoryManagerMXBean") ;

    try {
        ObjectName filterName =
                new ObjectName(ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE
                + ",*");
        Set<ObjectName> onSet = mbsc.queryNames(filterName, null);

        for (Iterator<ObjectName> iter = onSet.iterator(); iter.hasNext(); ) {
            ObjectName memoryManagerName = iter.next() ;
            System.out.println("-------- " + memoryManagerName) ;
            MBeanInfo mbInfo = mbsc.getMBeanInfo(memoryManagerName);
            System.out.println("getMBeanInfo\t\t" + mbInfo);
            errorCount += checkNonEmpty(mbInfo);
            MemoryManagerMXBean memoryManager = null;

            memoryManager =
                    JMX.newMXBeanProxy(mbsc,
                    memoryManagerName,
                    MemoryManagerMXBean.class) ;
            System.out.println("getMemoryPoolNames\t\t"
                    + Arrays.deepToString(memoryManager.getMemoryPoolNames()));
            System.out.println("getName\t\t"
                    + memoryManager.getName());
            System.out.println("isValid\t\t"
                    + memoryManager.isValid());
        }

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

    return errorCount ;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:40,代码来源:MXBeanInteropTest1.java


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