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");
}
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;
}
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();
}
}
Aggregations