src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp
Print this page
@@ -41,10 +41,11 @@
#include "gc_implementation/shared/gcHeapSummary.hpp"
#include "gc_implementation/shared/gcTimer.hpp"
#include "gc_implementation/shared/gcTrace.hpp"
#include "gc_implementation/shared/gcTraceTime.hpp"
#include "gc_implementation/shared/isGCActiveMark.hpp"
+#include "gc_implementation/shared/spaceDecorator.hpp"
#include "gc_interface/gcCause.hpp"
#include "memory/gcLocker.inline.hpp"
#include "memory/referencePolicy.hpp"
#include "memory/referenceProcessor.hpp"
#include "oops/methodData.hpp"
@@ -2113,10 +2114,17 @@
// Don't check if the size_policy is ready here. Let
// the size_policy check that internally.
if (UseAdaptiveGenerationSizePolicyAtMajorCollection &&
((gc_cause != GCCause::_java_lang_system_gc) ||
UseAdaptiveSizePolicyWithSystemGC)) {
+ // Swap the survivor spaces if from_space is empty
+ if (UseAdaptiveSizePolicyResizeYoungGenAtMajorCollection &&
+ young_gen->from_space()->is_empty()) {
+ young_gen->from_space()->clear(SpaceDecorator::Mangle);
+ young_gen->swap_spaces();
+ }
+
// Calculate optimal free space amounts
assert(young_gen->max_size() >
young_gen->from_space()->capacity_in_bytes() +
young_gen->to_space()->capacity_in_bytes(),
"Sizes of space in young gen are out-of-bounds");
@@ -2152,16 +2160,14 @@
size_policy->decay_supplemental_growth(true /* full gc*/);
heap->resize_old_gen(
size_policy->calculated_old_free_size_in_bytes());
- // Don't resize the young generation at an major collection. A
- // desired young generation size may have been calculated but
- // resizing the young generation complicates the code because the
- // resizing of the old generation may have moved the boundary
- // between the young generation and the old generation. Let the
- // young generation resizing happen at the minor collections.
+ if (UseAdaptiveSizePolicyResizeYoungGenAtMajorCollection) {
+ heap->resize_young_gen(size_policy->calculated_eden_size_in_bytes(),
+ size_policy->calculated_survivor_size_in_bytes());
+ }
}
if (PrintAdaptiveSizePolicy) {
gclog_or_tty->print_cr("AdaptiveSizeStop: collection: %d ",
heap->total_collections());
}