use of com.ibm.dtfj.java.JavaHeap in project openj9 by eclipse.
the class JavaObjectTest method loadTestObjects.
protected void loadTestObjects(JavaRuntime ddrRuntime, List<Object> ddrObjects, JavaRuntime jextractRuntime, List<Object> jextractObjects) {
List<Object> ddrHeaps = new ArrayList<Object>();
List<Object> jextractHeaps = new ArrayList<Object>();
gcpolicy = getVMoption(ddrRuntime, "-Xgcpolicy:");
if (gcpolicy.equals("gencon")) {
ddrHeaps.add(ddrRuntime.getHeaps().next());
jextractHeaps.add(jextractRuntime.getHeaps().next());
} else {
fillLists(ddrHeaps, ddrRuntime.getHeaps(), jextractHeaps, jextractRuntime.getHeaps(), null);
}
for (int i = 0; i < ddrHeaps.size(); i++) {
JavaHeap ddrHeap = (JavaHeap) ddrHeaps.get(i);
JavaHeap jextractHeap = (JavaHeap) jextractHeaps.get(i);
// this is a very simple grab of the first 10 objects off the heap which are not arrays and comparing them
fillObjectList(ddrObjects, ddrHeap.getObjects(), jextractObjects, jextractHeap.getObjects(), null, 10, false);
}
}
use of com.ibm.dtfj.java.JavaHeap in project openj9 by eclipse.
the class HeapdumpCommand method dumpMultipleHeapsInSeparateFiles.
private void dumpMultipleHeapsInSeparateFiles(JavaRuntime runtime, String version, boolean is64Bit, boolean phdFormat, String baseFileName, Set heapsToDump) throws IOException {
Iterator heapIterator = runtime.getHeaps();
HeapDumpFormatter formatter = null;
while (heapIterator.hasNext()) {
Object thisHeapObj = heapIterator.next();
if (thisHeapObj instanceof CorruptData) {
out.println("Heap corrupted at: " + ((CorruptData) thisHeapObj).getAddress());
_numberOfErrors++;
continue;
}
JavaHeap thisHeap = (JavaHeap) thisHeapObj;
// Create a new heapdump formatter for every heap we find
if (formatter != null) {
formatter.close();
}
if (heapsToDump.size() > 0 && !heapsToDump.contains(thisHeap.getName())) {
continue;
}
String fileName = getFileNameForHeap(thisHeap, baseFileName);
out.print("Writing " + (phdFormat ? "PHD" : "Classic") + " format heapdump for heap " + thisHeap.getName() + " into " + fileName + "\n");
formatter = getFormatter(fileName, version, is64Bit, phdFormat);
// We have to dump classes in every heapdump
dumpClasses(formatter, runtime);
dumpHeap(formatter, thisHeap);
}
if (formatter != null) {
formatter.close();
}
}
use of com.ibm.dtfj.java.JavaHeap in project openj9 by eclipse.
the class HeapdumpCommand method dumpMultipleHeapsInOneFile.
private void dumpMultipleHeapsInOneFile(JavaRuntime runtime, String version, boolean is64Bit, boolean phdFormat, String filename, Set heapsToDump) throws IOException {
Iterator heapIterator = runtime.getHeaps();
HeapDumpFormatter formatter = getFormatter(filename, version, is64Bit, phdFormat);
out.println("Writing " + (phdFormat ? "PHD" : "Classic") + " format heapdump into " + filename);
while (heapIterator.hasNext()) {
Object thisHeapObj = heapIterator.next();
if (thisHeapObj instanceof CorruptData) {
out.println("Corrupt heap data found at: " + ((CorruptData) thisHeapObj).getAddress());
_numberOfErrors++;
continue;
}
JavaHeap thisHeap = (JavaHeap) thisHeapObj;
if (heapsToDump.size() > 0 && !heapsToDump.contains(thisHeap.getName())) {
continue;
}
dumpHeap(formatter, thisHeap);
}
dumpClasses(formatter, runtime);
formatter.close();
}
use of com.ibm.dtfj.java.JavaHeap in project openj9 by eclipse.
the class HeapdumpCommand method heapArgumentsAreValid.
/**
* Checks the list of heaps to dump as specified by the user.
* @param runtime Current java runtime
* @param heapsToDump Set of strings the user passed as heaps to dump
* @return True if all the names are valid heaps, false otherwise
*/
private boolean heapArgumentsAreValid(JavaRuntime runtime, Set heapsToDump) {
if (heapsToDump.size() == 0) {
return true;
}
Set workingSet = new HashSet();
workingSet.addAll(heapsToDump);
Iterator heapIt = runtime.getHeaps();
while (heapIt.hasNext()) {
Object potential = heapIt.next();
if (potential instanceof JavaHeap) {
JavaHeap thisHeap = (JavaHeap) potential;
workingSet.remove(thisHeap.getName());
} else if (potential instanceof CorruptData) {
reportError("Corrupt heap found. Address = " + ((CorruptData) potential).getAddress(), null);
_numberOfErrors++;
} else {
_numberOfErrors++;
reportError("Unexpected type " + potential.getClass().getName() + " found in heap iterator", null);
}
}
if (workingSet.isEmpty()) {
return true;
} else {
StringBuffer buffer = new StringBuffer();
buffer.append("These specified heaps do not exist:\n");
Iterator nameIterator = workingSet.iterator();
while (nameIterator.hasNext()) {
buffer.append("\t\t" + nameIterator.next() + "\n");
}
buffer.append("\tUse \"info heap\" to see list of heap names");
out.println(buffer.toString());
return false;
}
}
use of com.ibm.dtfj.java.JavaHeap in project openj9 by eclipse.
the class XJCommand method printHeapObjects.
private void printHeapObjects(Long objAddress, String objName, PrintStream out, boolean supers) {
JavaRuntime jr = ctx.getRuntime();
JavaHeap jh;
Iterator<?> itHeap = jr.getHeaps();
int count = 1;
while (itHeap.hasNext()) {
Object obj = itHeap.next();
if (obj instanceof JavaHeap) {
jh = (JavaHeap) obj;
out.print("\t heap #" + count + " - name: ");
out.print(jh.getName());
out.print("\n\n");
printObjects(jh, objAddress, objName, out, supers, jr);
count++;
} else {
out.println("\t\tWarning : skipping corrupt heap");
}
}
}
Aggregations