Example usage for java.lang.management MemoryPoolMXBean setUsageThreshold

List of usage examples for java.lang.management MemoryPoolMXBean setUsageThreshold

Introduction

In this page you can find the example usage for java.lang.management MemoryPoolMXBean setUsageThreshold.

Prototype

public void setUsageThreshold(long threshold);

Source Link

Document

Sets the threshold of this memory pool to the given threshold value if this memory pool supports the usage threshold.

Usage

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

public static void setUsageThreshold(MemoryPoolMXBean memPool, double percentage) {
    MemoryUsage memUsage = memPool.getUsage();
    long max = memUsage.getMax();
    memPool.setUsageThreshold((long) (max * percentage));
}