< prev index next >
test/hotspot/jtreg/gc/g1/TestHumongousShrinkHeap.java
8217332: JTREG: Clean up, use generics instead of raw types
public class TestHumongousShrinkHeap {
public static final String MIN_FREE_RATIO_FLAG_NAME = "MinHeapFreeRatio";
public static final String MAX_FREE_RATIO_FLAG_NAME = "MaxHeapFreeRatio";
! private static final List<List<byte[]>> garbage = new ArrayList();
private static final int REGION_SIZE = 1024 * 1024; // 1M
private static final int LISTS_COUNT = 10;
private static final int HUMON_SIZE = Math.round(.9f * REGION_SIZE);
private static final long TOTAL_MEMORY = Runtime.getRuntime().totalMemory();
public class TestHumongousShrinkHeap {
public static final String MIN_FREE_RATIO_FLAG_NAME = "MinHeapFreeRatio";
public static final String MAX_FREE_RATIO_FLAG_NAME = "MaxHeapFreeRatio";
! private static final List<List<byte[]>> garbage = new ArrayList<>();
private static final int REGION_SIZE = 1024 * 1024; // 1M
private static final int LISTS_COUNT = 10;
private static final int HUMON_SIZE = Math.round(.9f * REGION_SIZE);
private static final long TOTAL_MEMORY = Runtime.getRuntime().totalMemory();
***************
}
private void allocate() {
for (int i = 0; i < LISTS_COUNT; i++) {
! List<byte[]> stuff = new ArrayList();
allocateList(stuff, HUMON_COUNT, HUMON_SIZE);
MemoryUsagePrinter.printMemoryUsage("allocate #" + (i+1));
garbage.add(stuff);
}
}
}
private void allocate() {
for (int i = 0; i < LISTS_COUNT; i++) {
! List<byte[]> stuff = new ArrayList<>();
allocateList(stuff, HUMON_COUNT, HUMON_SIZE);
MemoryUsagePrinter.printMemoryUsage("allocate #" + (i+1));
garbage.add(stuff);
}
}
***************
private void free() {
// do not free last one list
garbage.subList(0, garbage.size() - 1).clear();
// do not free last one element from last list
! List stuff = garbage.get(garbage.size() - 1);
stuff.subList(0, stuff.size() - 1).clear();
System.gc();
}
! private static void allocateList(List garbage, int count, int size) {
for (int i = 0; i < count; i++) {
garbage.add(new byte[size]);
}
}
}
private void free() {
// do not free last one list
garbage.subList(0, garbage.size() - 1).clear();
// do not free last one element from last list
! List<byte[]> stuff = garbage.get(garbage.size() - 1);
stuff.subList(0, stuff.size() - 1).clear();
System.gc();
}
! private static void allocateList(List<byte[]> garbage, int count, int size) {
for (int i = 0; i < count; i++) {
garbage.add(new byte[size]);
}
}
}
< prev index next >