Search in sources :

Example 6 with JavaHeap

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++;
    }
}
Also used : JavaHeap(com.ibm.dtfj.java.JavaHeap) Iterator(java.util.Iterator) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptData(com.ibm.dtfj.image.CorruptData)

Example 7 with JavaHeap

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++;
    }
}
Also used : JavaHeap(com.ibm.dtfj.java.JavaHeap) Iterator(java.util.Iterator)

Example 8 with JavaHeap

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;
}
Also used : JavaHeap(com.ibm.dtfj.java.JavaHeap) Iterator(java.util.Iterator) ImageSection(com.ibm.dtfj.image.ImageSection) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Example 9 with JavaHeap

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);
}
Also used : JavaObject(com.ibm.dtfj.java.JavaObject) JavaHeap(com.ibm.dtfj.java.JavaHeap) ImageSection(com.ibm.dtfj.image.ImageSection)

Example 10 with JavaHeap

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);
}
Also used : JavaRuntime(com.ibm.dtfj.java.JavaRuntime) JavaHeap(com.ibm.dtfj.java.JavaHeap) JavaObject(com.ibm.dtfj.java.JavaObject) Test(org.junit.Test)

Aggregations

JavaHeap (com.ibm.dtfj.java.JavaHeap)15 Iterator (java.util.Iterator)11 JavaObject (com.ibm.dtfj.java.JavaObject)10 CorruptData (com.ibm.dtfj.image.CorruptData)6 JavaRuntime (com.ibm.dtfj.java.JavaRuntime)4 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)3 ImageSection (com.ibm.dtfj.image.ImageSection)3 LongListReferenceIterator (com.ibm.jvm.dtfjview.heapdump.LongListReferenceIterator)3 ReferenceIterator (com.ibm.jvm.dtfjview.heapdump.ReferenceIterator)3 HeapDumpFormatter (com.ibm.jvm.dtfjview.heapdump.HeapDumpFormatter)2 ClassicHeapDumpFormatter (com.ibm.jvm.dtfjview.heapdump.classic.ClassicHeapDumpFormatter)2 PortableHeapDumpFormatter (com.ibm.jvm.dtfjview.heapdump.portable.PortableHeapDumpFormatter)2 ArrayList (java.util.ArrayList)2 ImageProcess (com.ibm.dtfj.image.ImageProcess)1 JavaClass (com.ibm.dtfj.java.JavaClass)1 ManagedRuntime (com.ibm.dtfj.runtime.ManagedRuntime)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Test (org.junit.Test)1