Search in sources :

Example 26 with MemoryUsage

use of java.lang.management.MemoryUsage in project jdk8u_jdk by JetBrains.

the class MemoryPoolImpl method setCollectionUsageThreshold.

public void setCollectionUsageThreshold(long newThreshold) {
    if (!isCollectionUsageThresholdSupported()) {
        throw new UnsupportedOperationException("CollectionUsage threshold is not supported");
    }
    Util.checkControlAccess();
    MemoryUsage usage = getUsage0();
    if (newThreshold < 0) {
        throw new IllegalArgumentException("Invalid threshold: " + newThreshold);
    }
    if (usage.getMax() != -1 && newThreshold > usage.getMax()) {
        throw new IllegalArgumentException("Invalid threshold: " + newThreshold + " > max (" + usage.getMax() + ").");
    }
    synchronized (this) {
        if (!gcSensorRegistered) {
            // pass the sensor to VM to begin monitoring
            gcSensorRegistered = true;
            setPoolCollectionSensor(gcSensor);
        }
        setCollectionThreshold0(collectionThreshold, newThreshold);
        this.collectionThreshold = newThreshold;
    }
}
Also used : MemoryUsage(java.lang.management.MemoryUsage)

Example 27 with MemoryUsage

use of java.lang.management.MemoryUsage in project jdk8u_jdk by JetBrains.

the class JvmMemPoolEntryImpl method getCollectMemoryUsage.

MemoryUsage getCollectMemoryUsage() {
    try {
        final Map<Object, Object> m = JvmContextFactory.getUserData();
        if (m != null) {
            final MemoryUsage cached = (MemoryUsage) m.get(entryCollectMemoryTag);
            if (cached != null) {
                if (log.isDebugOn())
                    log.debug("getCollectMemoryUsage", entryCollectMemoryTag + " found in cache.");
                return cached;
            }
            MemoryUsage u = pool.getCollectionUsage();
            if (u == null)
                u = ZEROS;
            m.put(entryCollectMemoryTag, u);
            return u;
        }
        // Should never come here.
        // Log error!
        log.trace("getCollectMemoryUsage", "ERROR: should never come here!");
        return ZEROS;
    } catch (RuntimeException x) {
        log.trace("getPeakMemoryUsage", "Failed to get MemoryUsage: " + x);
        log.debug("getPeakMemoryUsage", x);
        throw x;
    }
}
Also used : MemoryUsage(java.lang.management.MemoryUsage)

Example 28 with MemoryUsage

use of java.lang.management.MemoryUsage in project jdk8u_jdk by JetBrains.

the class JvmMemoryImpl method getHeapMemoryUsage.

MemoryUsage getHeapMemoryUsage() {
    try {
        final Map<Object, Object> m = JvmContextFactory.getUserData();
        if (m != null) {
            final MemoryUsage cached = (MemoryUsage) m.get(heapMemoryTag);
            if (cached != null) {
                log.debug("getHeapMemoryUsage", "jvmMemory.getHeapMemoryUsage found in cache.");
                return cached;
            }
            final MemoryUsage u = getMemoryUsage(MemoryType.HEAP);
            // getHeapMemoryUsage() never returns null.
            //
            // if (u == null) u=MemoryUsage.INVALID;
            m.put(heapMemoryTag, u);
            return u;
        }
        // Should never come here.
        // Log error!
        log.trace("getHeapMemoryUsage", "ERROR: should never come here!");
        return getMemoryUsage(MemoryType.HEAP);
    } catch (RuntimeException x) {
        log.trace("getHeapMemoryUsage", "Failed to get HeapMemoryUsage: " + x);
        log.debug("getHeapMemoryUsage", x);
        throw x;
    }
}
Also used : MemoryUsage(java.lang.management.MemoryUsage)

Example 29 with MemoryUsage

use of java.lang.management.MemoryUsage in project jdk8u_jdk by JetBrains.

the class JvmMemoryImpl method getNonHeapMemoryUsage.

MemoryUsage getNonHeapMemoryUsage() {
    try {
        final Map<Object, Object> m = JvmContextFactory.getUserData();
        if (m != null) {
            final MemoryUsage cached = (MemoryUsage) m.get(nonHeapMemoryTag);
            if (cached != null) {
                log.debug("getNonHeapMemoryUsage", "jvmMemory.getNonHeapMemoryUsage found in cache.");
                return cached;
            }
            final MemoryUsage u = getMemoryUsage(MemoryType.NON_HEAP);
            //  getNonHeapMemoryUsage() never returns null.
            //
            // if (u == null) u=MemoryUsage.INVALID;
            m.put(nonHeapMemoryTag, u);
            return u;
        }
        // Should never come here.
        // Log error!
        log.trace("getNonHeapMemoryUsage", "ERROR: should never come here!");
        return getMemoryUsage(MemoryType.NON_HEAP);
    } catch (RuntimeException x) {
        log.trace("getNonHeapMemoryUsage", "Failed to get NonHeapMemoryUsage: " + x);
        log.debug("getNonHeapMemoryUsage", x);
        throw x;
    }
}
Also used : MemoryUsage(java.lang.management.MemoryUsage)

Example 30 with MemoryUsage

use of java.lang.management.MemoryUsage in project jdk8u_jdk by JetBrains.

the class JvmMemPoolEntryImpl method getPeakMemoryUsage.

MemoryUsage getPeakMemoryUsage() {
    try {
        final Map<Object, Object> m = JvmContextFactory.getUserData();
        if (m != null) {
            final MemoryUsage cached = (MemoryUsage) m.get(entryPeakMemoryTag);
            if (cached != null) {
                if (log.isDebugOn())
                    log.debug("getPeakMemoryUsage", entryPeakMemoryTag + " found in cache.");
                return cached;
            }
            MemoryUsage u = pool.getPeakUsage();
            if (u == null)
                u = ZEROS;
            m.put(entryPeakMemoryTag, u);
            return u;
        }
        // Should never come here.
        // Log error!
        log.trace("getPeakMemoryUsage", "ERROR: should never come here!");
        return ZEROS;
    } catch (RuntimeException x) {
        log.trace("getPeakMemoryUsage", "Failed to get MemoryUsage: " + x);
        log.debug("getPeakMemoryUsage", x);
        throw x;
    }
}
Also used : MemoryUsage(java.lang.management.MemoryUsage)

Aggregations

MemoryUsage (java.lang.management.MemoryUsage)63 MemoryMXBean (java.lang.management.MemoryMXBean)13 MemoryPoolMXBean (java.lang.management.MemoryPoolMXBean)11 GarbageCollectorMXBean (java.lang.management.GarbageCollectorMXBean)6 RuntimeMXBean (java.lang.management.RuntimeMXBean)6 OperatingSystemMXBean (java.lang.management.OperatingSystemMXBean)4 ThreadMXBean (java.lang.management.ThreadMXBean)4 HashMap (java.util.HashMap)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 NotNull (org.jetbrains.annotations.NotNull)3 ApplicationInfo (com.intellij.openapi.application.ApplicationInfo)2 GarbageCollectionNotificationInfo (com.sun.management.GarbageCollectionNotificationInfo)2 BufferPoolMXBean (java.lang.management.BufferPoolMXBean)2 ClassLoadingMXBean (java.lang.management.ClassLoadingMXBean)2 Date (java.util.Date)2 CacheServiceMBean (org.apache.cassandra.service.CacheServiceMBean)2 Metric (com.codahale.metrics.Metric)1 RatioGauge (com.codahale.metrics.RatioGauge)1