Search in sources :

Example 61 with MemoryUsage

use of java.lang.management.MemoryUsage in project ignite by apache.

the class GridCapacityLoadTest method printHeap.

private static void printHeap(long init) {
    MemoryUsage heap = mem.getHeapMemoryUsage();
    long max = heap.getMax() - init;
    long used = heap.getUsed() - init;
    long left = max - used;
    X.println("Heap left: " + (left / (1024 * 1024)) + "MB");
}
Also used : MemoryUsage(java.lang.management.MemoryUsage)

Example 62 with MemoryUsage

use of java.lang.management.MemoryUsage in project ignite by apache.

the class GridManagerMxBeanIllegalArgumentHandleTest method createAlwaysFailingMxBean.

/** MX bean which is always failing to respond with metrics */
@NotNull
private MemoryMXBean createAlwaysFailingMxBean() {
    final Answer<MemoryUsage> failingAnswer = new Answer<MemoryUsage>() {

        @Override
        public MemoryUsage answer(InvocationOnMock invocationOnMock) throws Throwable {
            throw new IllegalArgumentException("java.lang.IllegalArgumentException: committed = 5274103808 should be < max = 5274095616");
        }
    };
    final MemoryMXBean memoryMXBean = Mockito.mock(MemoryMXBean.class);
    when(memoryMXBean.getHeapMemoryUsage()).thenAnswer(failingAnswer);
    when(memoryMXBean.getNonHeapMemoryUsage()).thenAnswer(failingAnswer);
    return memoryMXBean;
}
Also used : Answer(org.mockito.stubbing.Answer) MemoryMXBean(java.lang.management.MemoryMXBean) InvocationOnMock(org.mockito.invocation.InvocationOnMock) MemoryUsage(java.lang.management.MemoryUsage) NotNull(org.jetbrains.annotations.NotNull)

Example 63 with MemoryUsage

use of java.lang.management.MemoryUsage in project karaf by apache.

the class EnvironmentDumpProvider method dumpMemoryInformation.

private void dumpMemoryInformation(final PrintWriter outPW) {
    final MemoryMXBean mxBean = ManagementFactory.getMemoryMXBean();
    if (null == mxBean) {
        return;
    }
    final MemoryUsage heapMemoryUsage = mxBean.getHeapMemoryUsage();
    final MemoryUsage nonHeapMemoryUsage = mxBean.getNonHeapMemoryUsage();
    if (heapMemoryUsage != null) {
        outPW.println("HEAP Memory:");
        outPW.printf(INDENT_KEY_VALUE_FORMAT, "commited", printMemory(heapMemoryUsage.getCommitted())).println();
        outPW.printf(INDENT_KEY_VALUE_FORMAT, "init", printMemory(heapMemoryUsage.getInit())).println();
        outPW.printf(INDENT_KEY_VALUE_FORMAT, "used", printMemory(heapMemoryUsage.getUsed())).println();
        outPW.printf(INDENT_KEY_VALUE_FORMAT, "maximal", printMemory(heapMemoryUsage.getMax())).println();
    }
    if (nonHeapMemoryUsage != null) {
        outPW.println("NON-HEAP Memory:");
        outPW.printf(INDENT_KEY_VALUE_FORMAT, "commited", printMemory(nonHeapMemoryUsage.getCommitted())).println();
        outPW.printf(INDENT_KEY_VALUE_FORMAT, "init", printMemory(nonHeapMemoryUsage.getInit())).println();
        outPW.printf(INDENT_KEY_VALUE_FORMAT, "used", printMemory(nonHeapMemoryUsage.getUsed())).println();
        outPW.printf(INDENT_KEY_VALUE_FORMAT, "maximal", printMemory(nonHeapMemoryUsage.getMax())).println();
    }
}
Also used : MemoryMXBean(java.lang.management.MemoryMXBean) 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