Example usage for java.lang.management ManagementFactory getMemoryPoolMXBeans

List of usage examples for java.lang.management ManagementFactory getMemoryPoolMXBeans

Introduction

In this page you can find the example usage for java.lang.management ManagementFactory getMemoryPoolMXBeans.

Prototype

public static List<MemoryPoolMXBean> getMemoryPoolMXBeans() 

Source Link

Document

Returns a list of MemoryPoolMXBean objects in the Java virtual machine.

Usage

From source file:org.toobsframework.management.MemoryMonitor.java

private void init() {
    MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
    ((NotificationBroadcaster) mem).addNotificationListener(listener, null, null);

    for (MemoryPoolMXBean memPool : ManagementFactory.getMemoryPoolMXBeans()) {
        if (memPool.isUsageThresholdSupported()) {
            memPools.put(memPool.getName(), memPool);
            log.info("Putting Pool " + memPool.getName());
            setUsageThreshold(memPool, 0.7);
        }/*from  w w  w .  j  av a 2  s .c  o  m*/
    }
}