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


Java MemoryUsage.from方法代码示例

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


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

示例1: badTypeCompositeData

import java.lang.management.MemoryUsage; //导入方法依赖的package包/类
public static void badTypeCompositeData() throws Exception {
    final int K = 1024;
    final Object[] values = {
        new Integer(5 * K),
        new Long(1 * K),
        new Long(10 * K),
        new Long(2 * K),
        "Dummy",
        "Dummy",
    };

    CompositeType muct =
        new CompositeType("MyMemoryUsageCompositeType",
                          "CompositeType for MemoryUsage",
                          memoryUsageItemNames,
                          memoryUsageItemNames,
                          badMUItemTypes);
    CompositeData cd =
       new CompositeDataSupport(muct,
                                memoryUsageItemNames,
                                values);
    try {
        MemoryUsage u = MemoryUsage.from(cd);
    } catch (IllegalArgumentException e) {
        System.out.println("Expected exception: " +
            e.getMessage());
        return;
    }
    throw new RuntimeException(
        "IllegalArgumentException not thrown");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:32,代码来源:MemoryUsageCompositeData.java

示例2: badNameCompositeData

import java.lang.management.MemoryUsage; //导入方法依赖的package包/类
public static void badNameCompositeData() throws Exception {
    final int K = 1024;
    final Object[] values = {
        new Long(5 * K),
        new Long(1 * K),
        new Long(10 * K),
        new Long(2 * K),
        "Dummy",
        "Dummy",
    };

    CompositeType muct =
        new CompositeType("MyMemoryUsageCompositeType",
                          "CompositeType for MemoryUsage",
                           badMUItemNames,
                           badMUItemNames,
                           memoryUsageItemTypes);
    CompositeData cd =
        new CompositeDataSupport(muct,
                                 badMUItemNames,
                                 values);
    try {
        MemoryUsage u = MemoryUsage.from(cd);
    } catch (IllegalArgumentException e) {
        System.out.println("Expected exception: " +
            e.getMessage());
        return;
    }
    throw new RuntimeException(
        "IllegalArgumentException not thrown");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:32,代码来源:MemoryUsageCompositeData.java

示例3: getUsage

import java.lang.management.MemoryUsage; //导入方法依赖的package包/类
public static MemoryUsage getUsage(CompositeData cd) {
    CompositeData usageData = (CompositeData) cd.get(USAGE);
    return MemoryUsage.from(usageData);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:MemoryNotifInfoCompositeData.java

示例4: createGoodCompositeData

import java.lang.management.MemoryUsage; //导入方法依赖的package包/类
public static void createGoodCompositeData() throws Exception {
    final int K = 1024;
    // these values are synchronized with the item names
    final Object[] values = {
        new Long(5 * K),  // committed
        new Long(1 * K),  // init
        new Long(10 * K), // max
        new Long(2 * K),  // used
        "Dummy",
        "Dummy",
    };

    CompositeType muct =
        new CompositeType("MyMemoryUsageCompositeType",
                          "CompositeType for MemoryUsage",
                          memoryUsageItemNames,
                          memoryUsageItemNames,
                          memoryUsageItemTypes);
    CompositeData cd =
        new CompositeDataSupport(muct,
                                 memoryUsageItemNames,
                                 values);
    MemoryUsage u = MemoryUsage.from(cd);
    if (u.getInit() != ((Long) values[INIT]).longValue()) {
        throw new RuntimeException("init = " + u.getInit() +
           " expected = " + values[INIT]);
    }
    if (u.getUsed() != ((Long) values[USED]).longValue()) {
        throw new RuntimeException("used = " + u.getUsed() +
           " expected = " + values[USED]);
    }
    if (u.getCommitted() != ((Long) values[COMMITTED]).longValue()) {
        throw new RuntimeException("committed = " + u.getCommitted() +
           " expected = " + values[COMMITTED]);
    }
    if (u.getMax() != ((Long) values[MAX]).longValue()) {
        throw new RuntimeException("max = " + u.getMax() +
           " expected = " + values[MAX]);
    }
    System.out.println(u);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:42,代码来源:MemoryUsageCompositeData.java


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