7173044: MemoryMonitor hangs if getMax method in MemoryUsage object returns -1
Reviewed-by: dholmes, sspitsyn
--- a/jdk/src/share/demo/management/MemoryMonitor/MemoryMonitor.java Mon Jun 04 18:06:45 2012 +0800
+++ b/jdk/src/share/demo/management/MemoryMonitor/MemoryMonitor.java Tue Jun 05 10:16:22 2012 +0800
@@ -122,6 +122,7 @@
private Font font = new Font("Times New Roman", Font.PLAIN, 11);
private int columnInc;
private float usedMem[][];
+ private float usedMemMax[]; // Used when max pool size is undefined
private int ptNum[];
private int ascent, descent;
private Rectangle graphOutlineRect = new Rectangle();
@@ -142,6 +143,10 @@
}
});
usedMem = new float[numPools][];
+ usedMemMax = new float[numPools];
+ for (int i = 0; i < numPools; i++) {
+ usedMemMax[i] = 1024f * 1024f ;
+ }
ptNum = new int[numPools];
}
@@ -194,6 +199,12 @@
MemoryPoolMXBean mp = mpools.get(npool);
float usedMemory = mp.getUsage().getUsed();
float totalMemory = mp.getUsage().getMax();
+ if (totalMemory < 0) { // Max is undefined for this pool
+ if (usedMemory > usedMemMax[npool]) {
+ usedMemMax[npool] = usedMemory;
+ }
+ totalMemory = usedMemMax[npool];
+ }
// .. Draw allocated and used strings ..
big.setColor(Color.green);