private void dumpMultipleHeapsInSeparateFiles(JavaRuntime runtime,String version, boolean is64Bit, boolean phdFormat,String baseFileName, Set heapsToDump) throws IOException
{
Iterator heapIterator = runtime.getHeaps().iterator();
HeapDumpFormatter formatter = null;
while (heapIterator.hasNext()) {
Object thisHeapObj = heapIterator.next();
if (thisHeapObj instanceof CorruptData) {
out.error("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();
}
}