Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,13 @@ public String getName() {
}

@Override
public boolean shouldCollectCompletely(boolean followingIncrementalCollection) { // should_attempt_scavenge
public boolean shouldCollectCompletely(boolean followingIncrementalCollection, boolean forcedCompleteCollection) { // should_attempt_scavenge
guaranteeSizeParametersInitialized();

boolean collectYoungSeparately = shouldCollectYoungGenSeparately(!SerialGCOptions.useCompactingOldGen());
if (forcedCompleteCollection && !collectYoungSeparately) {
return true;
}
if (!followingIncrementalCollection && collectYoungSeparately) {
/*
* With a copying collector, default to always doing an incremental collection first
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public void onCollectionEnd(boolean completeCollection, GCCause cause) {
public static final class OnlyIncrementally extends BasicPolicy {

@Override
public boolean shouldCollectCompletely(boolean followingIncrementalCollection) {
public boolean shouldCollectCompletely(boolean followingIncrementalCollection, boolean forcedCompleteCollection) {
return false;
}

Expand All @@ -220,7 +220,7 @@ public String getName() {
public static final class OnlyCompletely extends BasicPolicy {

@Override
public boolean shouldCollectCompletely(boolean followingIncrementalCollection) {
public boolean shouldCollectCompletely(boolean followingIncrementalCollection, boolean forcedCompleteCollection) {
return followingIncrementalCollection || !shouldCollectYoungGenSeparately(false);
}

Expand All @@ -238,7 +238,7 @@ public boolean shouldCollectOnAllocation() {
}

@Override
public boolean shouldCollectCompletely(boolean followingIncrementalCollection) {
public boolean shouldCollectCompletely(boolean followingIncrementalCollection, boolean forcedCompleteCollection) {
throw VMError.shouldNotReachHere("Collection must not be initiated in the first place");
}

Expand All @@ -255,8 +255,12 @@ public String getName() {
public static final class BySpaceAndTime extends BasicPolicy {

@Override
public boolean shouldCollectCompletely(boolean followingIncrementalCollection) {
if (!followingIncrementalCollection && shouldCollectYoungGenSeparately(false)) {
public boolean shouldCollectCompletely(boolean followingIncrementalCollection, boolean forcedCompleteCollection) {
boolean collectYoungSeparately = shouldCollectYoungGenSeparately(false);
if (forcedCompleteCollection && !collectYoungSeparately) {
return true;
}
if (!followingIncrementalCollection && collectYoungSeparately) {
return false;
}
return estimateUsedHeapAtNextIncrementalCollection().aboveThan(getMaximumHeapSize()) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,10 @@ static boolean shouldCollectYoungGenSeparately(boolean defaultValue) {
* @param followingIncrementalCollection whether an incremental collection has just finished in
* the same safepoint. Implementations would typically decide whether to follow up
* with a full collection based on whether enough memory was reclaimed.
* @param forcedCompleteCollection whether a complete collection will eventually be forced. The
* policy can still return {@code false} to do an incremental collection first.
*/
boolean shouldCollectCompletely(boolean followingIncrementalCollection);
boolean shouldCollectCompletely(boolean followingIncrementalCollection, boolean forcedCompleteCollection);

/**
* The current limit for the size of the entire heap, which is less than or equal to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ private boolean doCollectImpl(GCCause cause, long initialBeginNanoTime, boolean

ChunkBasedCommittedMemoryProvider.get().beforeGarbageCollection();

boolean incremental = !forceNoIncremental && !policy.shouldCollectCompletely(false);
boolean incremental = !forceNoIncremental && !policy.shouldCollectCompletely(false, forceFullGC);
boolean outOfMemory = false;

if (incremental) {
Expand All @@ -330,7 +330,7 @@ private boolean doCollectImpl(GCCause cause, long initialBeginNanoTime, boolean
JfrGCEvents.emitGCPhasePauseEvent(getCollectionEpoch(), "Incremental GC", startTicks);
}
}
if (!incremental || outOfMemory || forceFullGC || policy.shouldCollectCompletely(incremental)) {
if (!incremental || outOfMemory || forceFullGC || policy.shouldCollectCompletely(incremental, forceFullGC)) {
long beginNanoTime = initialBeginNanoTime;
if (incremental) {
beginNanoTime = System.nanoTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,14 @@ public String getName() {
}

@Override
public boolean shouldCollectCompletely(boolean followingIncrementalCollection) {
public boolean shouldCollectCompletely(boolean followingIncrementalCollection, boolean forcedCompleteCollection) {
guaranteeSizeParametersInitialized();

if (!followingIncrementalCollection && shouldCollectYoungGenSeparately(false)) {
boolean collectYoungSeparately = shouldCollectYoungGenSeparately(false);
if (forcedCompleteCollection && !collectYoungSeparately) {
return true;
}
if (!followingIncrementalCollection && collectYoungSeparately) {
// Note that for non-ParallelGC, HotSpot resets the default of ScavengeBeforeFullGC to
// false, see GCArguments::initialize.
return false;
Expand Down