Merge
This commit is contained in:
commit
ccc0015fb4
@ -51,23 +51,29 @@ public class TestHumongousShrinkHeap {
|
||||
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 AVAILABLE_MEMORY
|
||||
= Runtime.getRuntime().freeMemory();
|
||||
private static final int HUMON_COUNT
|
||||
= (int) ((AVAILABLE_MEMORY / HUMON_SIZE)
|
||||
/ LISTS_COUNT);
|
||||
|
||||
private static final long TOTAL_MEMORY = Runtime.getRuntime().totalMemory();
|
||||
private static final long MAX_MEMORY = Runtime.getRuntime().maxMemory();
|
||||
|
||||
private static final int HUMON_COUNT = (int) ((TOTAL_MEMORY / HUMON_SIZE) / LISTS_COUNT);
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (HUMON_COUNT == 0) {
|
||||
System.out.println("Skipped. Heap is too small");
|
||||
return;
|
||||
}
|
||||
System.out.format("Running with %s max heap size. "
|
||||
+ "Will allocate humongous object of %s size %d times.%n",
|
||||
MemoryUsagePrinter.humanReadableByteCount(AVAILABLE_MEMORY, false),
|
||||
MemoryUsagePrinter.humanReadableByteCount(HUMON_SIZE, false),
|
||||
HUMON_COUNT
|
||||
|
||||
if (TOTAL_MEMORY + REGION_SIZE * HUMON_COUNT > MAX_MEMORY) {
|
||||
System.out.println("Skipped. Initial heap size is to close to max heap size.");
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.format("Running with %s initial heap size of %s maximum heap size. "
|
||||
+ "Will allocate humongous object of %s size %d times.%n",
|
||||
MemoryUsagePrinter.humanReadableByteCount(TOTAL_MEMORY, false),
|
||||
MemoryUsagePrinter.humanReadableByteCount(MAX_MEMORY, false),
|
||||
MemoryUsagePrinter.humanReadableByteCount(HUMON_SIZE, false),
|
||||
HUMON_COUNT
|
||||
);
|
||||
new TestHumongousShrinkHeap().test();
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ import utils.*;
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* @library /test/lib
|
||||
* @library ../share
|
||||
* @ignore 8155570
|
||||
* @run main/othervm -XX:+UsePerfData -Xmx128M -XX:MaxMetaspaceSize=128M GcTest02
|
||||
*/
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class GcProvokerImpl implements GcProvoker {
|
||||
used += memoryChunk;
|
||||
} catch (OutOfMemoryError e) {
|
||||
list = null;
|
||||
throw new RuntimeException("Unexpected OOME while eating " + targetUsage + " of heap memory.");
|
||||
throw new RuntimeException("Unexpected OOME '" + e.getMessage() + "' while eating " + targetUsage + " of heap memory.");
|
||||
}
|
||||
}
|
||||
return list;
|
||||
@ -73,8 +73,10 @@ public class GcProvokerImpl implements GcProvoker {
|
||||
|
||||
@Override
|
||||
public void eatMetaspaceAndHeap(float targetMemoryUsagePercent) {
|
||||
eatenMemory = eatHeapMemory(targetMemoryUsagePercent);
|
||||
// Metaspace should be filled before Java Heap to prevent unexpected OOME
|
||||
// in the Java Heap while filling Metaspace
|
||||
eatenMetaspace = eatMetaspace(targetMemoryUsagePercent);
|
||||
eatenMemory = eatHeapMemory(targetMemoryUsagePercent);
|
||||
}
|
||||
|
||||
private static List<Object> eatMetaspace(float targetUsage) {
|
||||
@ -97,7 +99,7 @@ public class GcProvokerImpl implements GcProvoker {
|
||||
list.add(gp.create(0));
|
||||
} catch (OutOfMemoryError oome) {
|
||||
list = null;
|
||||
throw new RuntimeException("Unexpected OOME while eating " + targetUsage + " of Metaspace.");
|
||||
throw new RuntimeException("Unexpected OOME '" + oome.getMessage() + "' while eating " + targetUsage + " of Metaspace.");
|
||||
}
|
||||
MemoryUsage memoryUsage = metaspacePool.getUsage();
|
||||
currentUsage = (((float) memoryUsage.getUsed()) / memoryUsage.getMax());
|
||||
|
Loading…
x
Reference in New Issue
Block a user