test/java/lang/management/MemoryMXBean/MemoryTest.java
Print this page
rev 5700 : 7195557: NPG: Unexpected number of memory pools
Summary: Update management tests to work with a VM without a permanent generation memory pool
Reviewed-by:
@@ -56,12 +56,15 @@
// or 4 if Class Sharing is enabled.
// Number of memory managers = 3
// They are: Copy/Scavenger + MSC + CodeCache manager
// (or equivalent for other collectors)
// Number of GC memory managers = 2
- private static int[] expectedMinNumPools = {3, 2};
- private static int[] expectedMaxNumPools = {3, 4};
+
+ // Hotspot VM 1.8+ after perm gen removal is expected to have only
+ // one non-heap memory pool
+ private static int[] expectedMinNumPools = {3, 1};
+ private static int[] expectedMaxNumPools = {3, 1};
private static int expectedNumGCMgrs = 2;
private static int expectedNumMgrs = expectedNumGCMgrs + 1;
private static String[] types = { "heap", "non-heap" };
public static void main(String args[]) throws Exception {
@@ -78,20 +81,31 @@
}
private static void checkMemoryPools() throws Exception {
List pools = ManagementFactory.getMemoryPoolMXBeans();
+ boolean hasPerm = false;
int[] numPools = new int[NUM_TYPES];
for (ListIterator iter = pools.listIterator(); iter.hasNext();) {
MemoryPoolMXBean pool = (MemoryPoolMXBean) iter.next();
if (pool.getType() == MemoryType.HEAP) {
numPools[HEAP]++;
}
if (pool.getType() == MemoryType.NON_HEAP) {
numPools[NONHEAP]++;
}
+ if (pool.getName().toLowerCase().contains("perm")) {
+ hasPerm = true;
+ }
+ }
+
+ if (hasPerm) {
+ // If the VM has perm gen there will be between 2 and 4 non heap
+ // pools (4 if class data sharing is used)
+ expectedMinNumPools[NONHEAP] = 2;
+ expectedMaxNumPools[NONHEAP] = 4;
}
// Check the number of Memory pools
for (int i = 0; i < NUM_TYPES; i++) {
if (numPools[i] < expectedMinNumPools[i] ||