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


Java MemoryMXBean.setVerbose方法代码示例

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


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

示例1: main

import java.lang.management.MemoryMXBean; //导入方法依赖的package包/类
public static void main(String[] args)
{
  MemoryMXBean bean = ManagementFactory.getMemoryMXBean();
  System.out.println("Bean: " + bean);
  System.out.println("Heap memory usage: "
                     + bean.getHeapMemoryUsage());
  System.out.println("Non-heap memory usage: "
                     + bean.getNonHeapMemoryUsage());
  System.out.println("Objects pending finalization: "
                     + bean.getObjectPendingFinalizationCount());
  System.out.println("Running garbage collector via bean...");
  bean.gc();
  System.out.println("Heap memory usage: "
                     + bean.getHeapMemoryUsage());
  System.out.println("Non-heap memory usage: "
                     + bean.getNonHeapMemoryUsage());
  System.out.println("Objects pending finalization: "
                     + bean.getObjectPendingFinalizationCount());
  boolean verbosity = bean.isVerbose();
  System.out.println("Verbose memory output: " + (verbosity ? "yes" : "no"));
  System.out.println("Changing verbose setting...");
  bean.setVerbose(!verbosity);
  System.out.println("Verbose memory output: " + (bean.isVerbose() ? "yes" : "no"));
}
 
开发者ID:vilie,项目名称:javify,代码行数:25,代码来源:TestMemory.java

示例2: main

import java.lang.management.MemoryMXBean; //导入方法依赖的package包/类
public static void main(String[] args)
{
  MemoryMXBean bean = ManagementFactory.getMemoryMXBean();
  System.out.println("Bean: " + bean);
  System.out.println("Heap memory usage: " 
       + bean.getHeapMemoryUsage());
  System.out.println("Non-heap memory usage: " 
       + bean.getNonHeapMemoryUsage());
  System.out.println("Objects pending finalization: " 
       + bean.getObjectPendingFinalizationCount());
  System.out.println("Running garbage collector via bean...");
  bean.gc();
  System.out.println("Heap memory usage: " 
       + bean.getHeapMemoryUsage());
  System.out.println("Non-heap memory usage: " 
       + bean.getNonHeapMemoryUsage());
  System.out.println("Objects pending finalization: " 
       + bean.getObjectPendingFinalizationCount());
  boolean verbosity = bean.isVerbose();
  System.out.println("Verbose memory output: " + (verbosity ? "yes" : "no"));
  System.out.println("Changing verbose setting...");
  bean.setVerbose(!verbosity);
  System.out.println("Verbose memory output: " + (bean.isVerbose() ? "yes" : "no"));
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:25,代码来源:TestMemory.java

示例3: testMemoryMXBean

import java.lang.management.MemoryMXBean; //导入方法依赖的package包/类
@Test
public void testMemoryMXBean() throws IOException {
    DescribedResource describedResource = basicResourceTest("memory", null);

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

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

    // Restore
    mbean.setVerbose(verbose);

    op = getOperation("gc", "memory", null);
    Assert.assertFalse(executeOp(op, false).isDefined());
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:21,代码来源:PlatformMBeanResourceUnitTestCase.java

示例4: displayManagementBean

import java.lang.management.MemoryMXBean; //导入方法依赖的package包/类
private String displayManagementBean(MemoryMXBean mxBean) {
    StringBuilder sb = new StringBuilder();
    if (mxBean != null) {
        mxBean.setVerbose(true);
        sb.append("Memory object name:\t").append(mxBean.getObjectName()).append('\n');
        sb.append("Heap usage:\t").append(mxBean.getHeapMemoryUsage()).append('\n');
        sb.append("Non-heap usage:\t").append(mxBean.getNonHeapMemoryUsage()).append('\n');
        sb.append("ObjectPendingFinalizationCount:\t").append(mxBean.getObjectPendingFinalizationCount()).append('\n');
    }
    return sb.toString();
}
 
开发者ID:jwoehr,项目名称:ublu,代码行数:12,代码来源:JVMHelper.java

示例5: testNewPlatformMXBeanProxy_MemoryMXBean

import java.lang.management.MemoryMXBean; //导入方法依赖的package包/类
public void testNewPlatformMXBeanProxy_MemoryMXBean() throws Exception {
    MemoryMXBean proxy = ManagementFactory.newPlatformMXBeanProxy(
            ManagementFactory.getPlatformMBeanServer(),
            "java.lang:type=Memory", MemoryMXBean.class);
    assertNotNull(proxy);
    MemoryMXBean mb = ManagementFactory.getMemoryMXBean();
    // RI's MemoryUsage does not appear to override equals() so we have to
    // go the long way round to check that the answers match...
    MemoryUsage mu1 = mb.getHeapMemoryUsage();
    MemoryUsage mu2 = proxy.getHeapMemoryUsage();
    assertEquals(mu1.getInit(), mu2.getInit());
    assertEquals(mu1.getMax(), mu2.getMax());

    mu1 = mb.getNonHeapMemoryUsage();
    mu2 = proxy.getNonHeapMemoryUsage();
    assertEquals(mu1.getInit(), mu2.getInit());
    assertEquals(mu1.getMax(), mu2.getMax());

    assertEquals(mb.isVerbose(), proxy.isVerbose());
    // changes made to proxy should be seen in the "real bean" and
    // vice versa
    boolean initialValue = proxy.isVerbose();
    mb.setVerbose(!initialValue);
    assertEquals(!initialValue, proxy.isVerbose());
    proxy.setVerbose(initialValue);
    assertEquals(initialValue, mb.isVerbose());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:28,代码来源:ManagementFactoryTest.java


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