use of com.ibm.dtfj.java.JavaHeap in project openj9 by eclipse.
the class DTFJHeapUnitTest method generateXML.
@SuppressWarnings("unchecked")
public void generateXML(File path, JavaRuntime rt) throws Exception {
createWriter(path);
startTag("<heaps>\n");
for (Iterator heaps = rt.getHeaps(); heaps.hasNext(); ) {
JavaHeap heap = (JavaHeap) heaps.next();
writeIndent();
startTag("<heap name=\"" + heap.getName() + "\">\n");
long count = 0;
for (Iterator objects = heap.getObjects(); objects.hasNext(); count++) {
try {
JavaObject obj = (JavaObject) objects.next();
if (((count % 100) == 0) || (obj.isArray())) {
writeObject(obj, count);
}
} catch (CorruptDataException e) {
write("<!-- corrupt object @ " + e.getCorruptData().getAddress() + " -->");
}
}
startTag("<objects count=\"" + count + "\">\n");
endTag("</objects>\n");
endTag("</heap>\n");
}
endTag("</heaps>\n");
closeWriter();
}
use of com.ibm.dtfj.java.JavaHeap in project openj9 by eclipse.
the class DTFJHeapSectionUnitTest method generateXML.
@SuppressWarnings("unchecked")
public void generateXML(File path, JavaRuntime rt) throws Exception {
createWriter(path);
startTag("<heaps>\n");
for (Iterator heaps = rt.getHeaps(); heaps.hasNext(); ) {
JavaHeap heap = (JavaHeap) heaps.next();
startTag("<heap name=\"" + heap.getName() + "\">\n");
writeSections(heap);
endTag("</heap>\n");
}
endTag("</heaps>\n");
closeWriter();
}
use of com.ibm.dtfj.java.JavaHeap in project openj9 by eclipse.
the class PHDImageAddressSpace method getImageSections.
public Iterator<ImageSection> getImageSections() {
List<ImageSection> list = new ArrayList<ImageSection>();
for (Iterator<ImageProcess> ip = getProcesses(); ip.hasNext(); ) {
ImageProcess p = ip.next();
if (p instanceof CorruptData)
continue;
for (Iterator<ManagedRuntime> jr = p.getRuntimes(); jr.hasNext(); ) {
ManagedRuntime mr = jr.next();
if (mr instanceof CorruptData)
continue;
if (mr instanceof JavaRuntime) {
for (Iterator<JavaHeap> jh = ((JavaRuntime) mr).getHeaps(); jh.hasNext(); ) {
JavaHeap hp = jh.next();
if (hp instanceof CorruptData)
continue;
for (Iterator<ImageSection> is = hp.getSections(); is.hasNext(); ) {
// Add the corrupt sections too
list.add(is.next());
}
}
}
}
}
if (metaImageAddressSpace != null) {
for (Iterator it = metaImageAddressSpace.getImageSections(); it.hasNext(); ) {
Object next = it.next();
if (next instanceof ImageSection) {
ImageSection section = (ImageSection) next;
ImageSection newSection = new PHDImageSection(section.getName(), getPointer(section.getBaseAddress().getAddress()), section.getSize());
list.add(newSection);
}
}
}
return list.iterator();
}
use of com.ibm.dtfj.java.JavaHeap in project openj9 by eclipse.
the class InfoClassCommand method countClassInstances.
private void countClassInstances() {
JavaRuntime runtime = ctx.getRuntime();
Map<JavaClass, ClassStatistics> thisRuntimeClasses = classInstanceCounts.get(runtime);
final Collection<JavaClass> javaClasses = getRuntimeClasses(runtime);
long corruptObjectCount = 0;
long corruptClassCount = 0;
long corruptClassNameCount = 0;
Iterator itHeap = runtime.getHeaps();
while (itHeap.hasNext()) {
Object heap = itHeap.next();
if (heap instanceof CorruptData) {
out.println("[skipping corrupt heap]");
continue;
}
JavaHeap jh = (JavaHeap) heap;
Iterator itObject = jh.getObjects();
// Walk through all objects in this heap, accumulating counts and total memory size by class
while (itObject.hasNext()) {
Object next = itObject.next();
// JavaHeap, we don't attempt to count these as instances of known classes).
if (next instanceof JavaObject) {
JavaObject jo = (JavaObject) next;
ClassStatistics stats = null;
try {
// Check whether we found this class in the classloaders walk earlier
JavaClass jc = jo.getJavaClass();
if (javaClasses.contains(jc)) {
stats = thisRuntimeClasses.get(jc);
} else {
// Class not found in the classloaders, create a statistic for it now, and issue a warning message
stats = new ClassStatistics();
thisRuntimeClasses.put(jc, stats);
String classname;
try {
classname = jc.getName();
out.println("Warning, class: " + classname + " found when walking the heap was missing from classloader walk");
} catch (CorruptDataException cde) {
corruptClassNameCount++;
}
}
// Increment the statistic for objects of this class (accumulated count and size)
stats.incrementCount();
try {
stats.addToSize(jo.getSize());
} catch (CorruptDataException cde) {
// bad size, count object as corrupt
corruptObjectCount++;
}
} catch (CorruptDataException cde) {
corruptClassCount++;
}
} else {
corruptObjectCount++;
}
}
}
if (corruptObjectCount != 0) {
out.println("Warning, found " + corruptObjectCount + " corrupt objects during heap walk");
}
if (corruptClassCount != 0) {
out.println("Warning, found " + corruptClassCount + " corrupt class references during heap walk");
}
if (corruptClassNameCount != 0) {
out.println("Warning, found " + corruptClassNameCount + " corrupt class names during heap walk");
}
}
use of com.ibm.dtfj.java.JavaHeap in project openj9 by eclipse.
the class InfoHeapCommand method searchForHeap.
private boolean searchForHeap(String param, JavaRuntime jr, PrintStream out) {
boolean foundHeap = false;
Iterator itHeaps = jr.getHeaps();
int countheaps = 1;
while (itHeaps.hasNext()) {
JavaHeap theHeap = (JavaHeap) itHeaps.next();
if (theHeap.getName().indexOf(param) == 0) {
out.print("\t Heap #" + countheaps + ": " + theHeap.getName() + "\n");
printOccupancyInfo(theHeap, out);
printSectionInfo(theHeap, out);
foundHeap = true;
}
countheaps++;
}
return foundHeap;
}
Aggregations