當前位置: 首頁>>代碼示例>>Java>>正文


Java MemoryMXBean.isVerbose方法代碼示例

本文整理匯總了Java中java.lang.management.MemoryMXBean.isVerbose方法的典型用法代碼示例。如果您正苦於以下問題:Java MemoryMXBean.isVerbose方法的具體用法?Java MemoryMXBean.isVerbose怎麽用?Java MemoryMXBean.isVerbose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.lang.management.MemoryMXBean的用法示例。


在下文中一共展示了MemoryMXBean.isVerbose方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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.isVerbose方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。