< prev index next >
test/serviceability/tmtools/jstat/utils/GcProvokerImpl.java
Print this page
rev 11458 : imported patch 8149778
*** 40,51 ****
static List<Object> eatHeapMemory(float targetUsage) {
long maxMemory = Runtime.getRuntime().maxMemory();
// uses fixed small objects to avoid Humongous objects allocation in G1
int memoryChunk = 2048;
List<Object> list = new ArrayList<>();
! float used = 0;
! while (used < targetUsage * maxMemory) {
try {
list.add(new byte[memoryChunk]);
used += memoryChunk;
} catch (OutOfMemoryError e) {
list = null;
--- 40,52 ----
static List<Object> eatHeapMemory(float targetUsage) {
long maxMemory = Runtime.getRuntime().maxMemory();
// uses fixed small objects to avoid Humongous objects allocation in G1
int memoryChunk = 2048;
List<Object> list = new ArrayList<>();
! long used = 0;
! long target = (long) (maxMemory * targetUsage);
! while (used < target) {
try {
list.add(new byte[memoryChunk]);
used += memoryChunk;
} catch (OutOfMemoryError e) {
list = null;
< prev index next >