use of com.ibm.dtfj.java.JavaHeap in project openj9 by eclipse.
the class InfoHeapCommand method printHeapInfo.
private void printHeapInfo(String param, JavaRuntime runtime, PrintStream out) {
Iterator itHeaps = runtime.getHeaps();
int countheaps = 1;
while (itHeaps.hasNext()) {
Object heap = itHeaps.next();
if (heap instanceof CorruptData) {
out.println("[skipping corrupt heap");
continue;
}
JavaHeap theHeap = (JavaHeap) heap;
out.print("\t Heap #" + countheaps + ": " + theHeap.getName() + "\n");
if (param != null) {
printSectionInfo(theHeap, out);
}
countheaps++;
}
}
use of com.ibm.dtfj.java.JavaHeap in project openj9 by eclipse.
the class WhatisCommand method findInRuntime.
private void findInRuntime(long address) {
JavaHeap jh;
Iterator itHeap = ctx.getRuntime().getHeaps();
int count = 1;
while (itHeap.hasNext()) {
jh = (JavaHeap) itHeap.next();
out.print("\theap #" + count + " - name: ");
out.print(jh.getName() + "\n");
findInHeap(jh, address);
count++;
}
}
use of com.ibm.dtfj.java.JavaHeap in project openj9 by eclipse.
the class DTFJJavaRuntimeHelper method getTotalHeapSize.
@SuppressWarnings("rawtypes")
public static long getTotalHeapSize(JavaRuntime runtime, IProcess process) throws CorruptDataException {
if (totalSizeOfAllHeaps > 0) {
// already calculated, never changes
return totalSizeOfAllHeaps;
}
if (runtime == null) {
throw new com.ibm.dtfj.image.CorruptDataException(J9DDRDTFJUtils.newCorruptData(process, "No Java Runtime present"));
}
Iterator heaps = runtime.getHeaps();
while (heaps.hasNext()) {
Object nextHeap = heaps.next();
Iterator sections;
if (nextHeap instanceof JavaHeap) {
sections = ((JavaHeap) nextHeap).getSections();
} else {
// CorruptData?
throw new com.ibm.dtfj.image.CorruptDataException(J9DDRDTFJUtils.newCorruptData(process, "Corrupt heap encountered whilst calculating total heap size"));
}
while (sections.hasNext()) {
Object nextSection = sections.next();
if (nextSection instanceof ImageSection) {
long sectionSize = ((ImageSection) nextSection).getSize();
if (Long.MAX_VALUE - sectionSize > totalSizeOfAllHeaps) {
totalSizeOfAllHeaps += sectionSize;
} else {
// no point adding further, the cap is on Long.MAX_VALUE
return Long.MAX_VALUE;
}
} else {
// CorruptData?
throw new com.ibm.dtfj.image.CorruptDataException(J9DDRDTFJUtils.newCorruptData(process, "Corrupt section encountered whilst calculating total heap size"));
}
}
}
return totalSizeOfAllHeaps;
}
use of com.ibm.dtfj.java.JavaHeap in project openj9 by eclipse.
the class JavaHeapComparator method testEquals.
// getName()
// getObjects()
// getSections()
public void testEquals(Object ddrObject, Object jextractObject, int members) {
JavaHeap ddrjJavaHeap = (JavaHeap) ddrObject;
JavaHeap jextractJavaHeap = (JavaHeap) jextractObject;
// getName()
if ((NAME & members) != 0)
testJavaEquals(ddrjJavaHeap, jextractJavaHeap, "getName");
// getObjects()
if ((OBJECTS & members) != 0)
new JavaObjectComparator().testComparatorIteratorEquals(ddrjJavaHeap, jextractJavaHeap, "getObjects", JavaObject.class);
// getSections
if ((SECTIONS & members) != 0)
new ImageSectionComparator().testComparatorIteratorEquals(ddrjJavaHeap, jextractJavaHeap, "getSections", ImageSection.class);
}
use of com.ibm.dtfj.java.JavaHeap in project openj9 by eclipse.
the class JavaRuntimeTest method getHeapsTest.
@Test
public void getHeapsTest() {
Iterator<Object> iter = ((JavaRuntime) ddrTestObjects.get(0)).getHeaps();
while (iter.hasNext()) {
JavaHeap heap = (JavaHeap) iter.next();
Iterator<Object> objectIter = heap.getObjects();
int count = 0;
while (objectIter.hasNext()) {
// JavaObject javaObject = (JavaObject) objectIter.next();
// System.out.println(javaObject.get);
count++;
objectIter.next();
}
System.out.println(heap.getName() + ": " + count);
}
javaHeapComparator.testComparatorIteratorEquals(ddrTestObjects, jextractTestObjects, "getHeaps", JavaHeap.class);
}
Aggregations