Java Code Examples for java.lang.management.MemoryMXBean.isVerbose()

The following are Jave code examples for showing how to use isVerbose() of the java.lang.management.MemoryMXBean class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: javify   File: TestMemory.java   View Source Code Vote up 6 votes
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"));
}
 
Example 2
Project: jvm-stm   File: TestMemory.java   View Source Code Vote up 6 votes
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"));
}
 
Example 3
Project: JamVM-PH   File: TestMemory.java   View Source Code Vote up 6 votes
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"));
}
 
Example 4
Project: classpath   File: TestMemory.java   View Source Code Vote up 6 votes
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"));
}
 
Example 5
Project: cn1   File: ManagementFactoryTest.java   View Source Code Vote up 5 votes
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());
}
 
Example 6
Project: freeVM   File: ManagementFactoryTest.java   View Source Code Vote up 5 votes
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());
}
 
Example 7
Project: freeVM   File: ManagementFactoryTest.java   View Source Code Vote up 5 votes
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());
}