C/Wasm: fix OOME from compiled application

This commit is contained in:
Alexey Andreev 2019-12-05 16:32:52 +03:00
parent 236c6191c2
commit 1ac0f7156c

View File

@ -167,8 +167,13 @@ public final class GC {
private static void collectGarbageImpl(int size) { private static void collectGarbageImpl(int size) {
doCollectGarbage(); doCollectGarbage();
long minRequestedSize = 0;
if (!hasAvailableChunk(size)) {
minRequestedSize = computeMinRequestedSize(size);
}
if (!isFullGC) { if (!isFullGC) {
if (++youngGCCount >= 8 && isAboutToExpand(size)) { if (++youngGCCount >= 8 && isAboutToExpand(minRequestedSize)) {
triggerFullGC(); triggerFullGC();
doCollectGarbage(); doCollectGarbage();
youngGCCount = 0; youngGCCount = 0;
@ -178,10 +183,6 @@ public final class GC {
} }
isFullGC = false; isFullGC = false;
long minRequestedSize = 0;
if (!hasAvailableChunk(size)) {
minRequestedSize = computeMinRequestedSize(size);
}
resizeHeapIfNecessary(minRequestedSize); resizeHeapIfNecessary(minRequestedSize);
currentChunk = currentChunkPointer.value; currentChunk = currentChunkPointer.value;
currentChunkLimit = currentChunk.toAddress().add(currentChunk.size); currentChunkLimit = currentChunk.toAddress().add(currentChunk.size);