TreeSet setMemory = null;
// para ordenar pelo maior tempo
setMemory = new TreeSet(new Comparator() {
public int compare(Object o1, Object o2) {
JBPMemoryCount s1 = (JBPMemoryCount) o1;
JBPGenericCount s2 = (JBPGenericCount) o2;
int x = s2.getCount() - s1.getCount();
if (x != 0) {
return x;
} else if (((JBPClass) s1.getReferencedObject()).getName() != null
&& ((JBPClass) s2.getReferencedObject()).getName() != null) {
return ((JBPClass) s1.getReferencedObject()).getName()
.compareTo(
((JBPClass) s2.getReferencedObject())
.getName());
} else {
return ((JBPClass) s1.getReferencedObject()).getClassID()
- ((JBPClass) s2.getReferencedObject())
.getClassID();
}
}
});
HashMap hashMemory = count.createConsolidatedObjects();
setMemory.addAll(hashMemory.values());
printLevel(out, level);
out.println("<memory>");
Iterator iter = setMemory.iterator();
while (iter.hasNext()) {
JBPMemoryCount iterCount = (JBPMemoryCount) iter.next();
JBPClass spyClass = (JBPClass) iterCount.getReferencedObject();
for (int i = 0; i <= level; i++) {
out.print(IDENT_ON_LEVEL);
}
out.println("<memoryItem instanceOf=\"" + spyClass.getName()
+ "\" instances=\"" + iterCount.getCount() + "\" bytes=\""
+ iterCount.getSize() + "\"" + " releasedInstances=\""
+ iterCount.getCountRelease() + "\" releasedBytes=\""
+ iterCount.getReleasedSize() + "\"/>");
}
for (int i = 0; i < level; i++) {
out.print(IDENT_ON_LEVEL);