src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp

Print this page




 263     size_policy->major_collection_end(old_gen->used_in_bytes(), gc_cause);
 264 
 265     if (UseAdaptiveSizePolicy) {
 266 
 267       if (PrintAdaptiveSizePolicy) {
 268         gclog_or_tty->print("AdaptiveSizeStart: ");
 269         gclog_or_tty->stamp();
 270         gclog_or_tty->print_cr(" collection: %d ",
 271                        heap->total_collections());
 272         if (Verbose) {
 273           gclog_or_tty->print("old_gen_capacity: %d young_gen_capacity: %d",
 274             old_gen->capacity_in_bytes(), young_gen->capacity_in_bytes());
 275         }
 276       }
 277 
 278       // Don't check if the size_policy is ready here.  Let
 279       // the size_policy check that internally.
 280       if (UseAdaptiveGenerationSizePolicyAtMajorCollection &&
 281           ((gc_cause != GCCause::_java_lang_system_gc) ||
 282             UseAdaptiveSizePolicyWithSystemGC)) {







 283         // Calculate optimal free space amounts
 284         assert(young_gen->max_size() >
 285           young_gen->from_space()->capacity_in_bytes() +
 286           young_gen->to_space()->capacity_in_bytes(),
 287           "Sizes of space in young gen are out-of-bounds");
 288 
 289         size_t young_live = young_gen->used_in_bytes();
 290         size_t eden_live = young_gen->eden_space()->used_in_bytes();
 291         size_t old_live = old_gen->used_in_bytes();
 292         size_t cur_eden = young_gen->eden_space()->capacity_in_bytes();
 293         size_t max_old_gen_size = old_gen->max_gen_size();
 294         size_t max_eden_size = young_gen->max_size() -
 295           young_gen->from_space()->capacity_in_bytes() -
 296           young_gen->to_space()->capacity_in_bytes();
 297 
 298         // Used for diagnostics
 299         size_policy->clear_generation_free_space_flags();
 300 
 301         size_policy->compute_generations_free_space(young_live,
 302                                                     eden_live,
 303                                                     old_live,
 304                                                     cur_eden,
 305                                                     max_old_gen_size,
 306                                                     max_eden_size,
 307                                                     true /* full gc*/);
 308 
 309         size_policy->check_gc_overhead_limit(young_live,
 310                                              eden_live,
 311                                              max_old_gen_size,
 312                                              max_eden_size,
 313                                              true /* full gc*/,
 314                                              gc_cause,
 315                                              heap->collector_policy());
 316 
 317         size_policy->decay_supplemental_growth(true /* full gc*/);
 318 
 319         heap->resize_old_gen(size_policy->calculated_old_free_size_in_bytes());
 320 
 321         // Don't resize the young generation at an major collection.  A
 322         // desired young generation size may have been calculated but
 323         // resizing the young generation complicates the code because the
 324         // resizing of the old generation may have moved the boundary
 325         // between the young generation and the old generation.  Let the
 326         // young generation resizing happen at the minor collections.
 327       }
 328       if (PrintAdaptiveSizePolicy) {
 329         gclog_or_tty->print_cr("AdaptiveSizeStop: collection: %d ",
 330                        heap->total_collections());
 331       }
 332     }
 333 
 334     if (UsePerfData) {
 335       heap->gc_policy_counters()->update_counters();
 336       heap->gc_policy_counters()->update_old_capacity(
 337         old_gen->capacity_in_bytes());
 338       heap->gc_policy_counters()->update_young_capacity(
 339         young_gen->capacity_in_bytes());
 340     }
 341 
 342     heap->resize_all_tlabs();
 343 
 344     // We collected the heap, recalculate the metaspace capacity
 345     MetaspaceGC::compute_new_size();
 346 




 263     size_policy->major_collection_end(old_gen->used_in_bytes(), gc_cause);
 264 
 265     if (UseAdaptiveSizePolicy) {
 266 
 267       if (PrintAdaptiveSizePolicy) {
 268         gclog_or_tty->print("AdaptiveSizeStart: ");
 269         gclog_or_tty->stamp();
 270         gclog_or_tty->print_cr(" collection: %d ",
 271                        heap->total_collections());
 272         if (Verbose) {
 273           gclog_or_tty->print("old_gen_capacity: %d young_gen_capacity: %d",
 274             old_gen->capacity_in_bytes(), young_gen->capacity_in_bytes());
 275         }
 276       }
 277 
 278       // Don't check if the size_policy is ready here.  Let
 279       // the size_policy check that internally.
 280       if (UseAdaptiveGenerationSizePolicyAtMajorCollection &&
 281           ((gc_cause != GCCause::_java_lang_system_gc) ||
 282             UseAdaptiveSizePolicyWithSystemGC)) {
 283         // Swap the survivor spaces if from_space is empty
 284         if (UseAdaptiveSizePolicyResizeYoungGenAtMajorCollection &&
 285             young_gen->from_space()->is_empty()) {
 286           young_gen->from_space()->clear(SpaceDecorator::Mangle);
 287           young_gen->swap_spaces();
 288         }
 289 
 290         // Calculate optimal free space amounts
 291         assert(young_gen->max_size() >
 292           young_gen->from_space()->capacity_in_bytes() +
 293           young_gen->to_space()->capacity_in_bytes(),
 294           "Sizes of space in young gen are out-of-bounds");
 295 
 296         size_t young_live = young_gen->used_in_bytes();
 297         size_t eden_live = young_gen->eden_space()->used_in_bytes();
 298         size_t old_live = old_gen->used_in_bytes();
 299         size_t cur_eden = young_gen->eden_space()->capacity_in_bytes();
 300         size_t max_old_gen_size = old_gen->max_gen_size();
 301         size_t max_eden_size = young_gen->max_size() -
 302           young_gen->from_space()->capacity_in_bytes() -
 303           young_gen->to_space()->capacity_in_bytes();
 304 
 305         // Used for diagnostics
 306         size_policy->clear_generation_free_space_flags();
 307 
 308         size_policy->compute_generations_free_space(young_live,
 309                                                     eden_live,
 310                                                     old_live,
 311                                                     cur_eden,
 312                                                     max_old_gen_size,
 313                                                     max_eden_size,
 314                                                     true /* full gc*/);
 315 
 316         size_policy->check_gc_overhead_limit(young_live,
 317                                              eden_live,
 318                                              max_old_gen_size,
 319                                              max_eden_size,
 320                                              true /* full gc*/,
 321                                              gc_cause,
 322                                              heap->collector_policy());
 323 
 324         size_policy->decay_supplemental_growth(true /* full gc*/);
 325 
 326         heap->resize_old_gen(size_policy->calculated_old_free_size_in_bytes());
 327 
 328         if (UseAdaptiveSizePolicyResizeYoungGenAtMajorCollection) {
 329           heap->resize_young_gen(size_policy->calculated_eden_size_in_bytes(),
 330                                  size_policy->calculated_survivor_size_in_bytes());
 331         }


 332       }
 333       if (PrintAdaptiveSizePolicy) {
 334         gclog_or_tty->print_cr("AdaptiveSizeStop: collection: %d ",
 335                        heap->total_collections());
 336       }
 337     }
 338 
 339     if (UsePerfData) {
 340       heap->gc_policy_counters()->update_counters();
 341       heap->gc_policy_counters()->update_old_capacity(
 342         old_gen->capacity_in_bytes());
 343       heap->gc_policy_counters()->update_young_capacity(
 344         young_gen->capacity_in_bytes());
 345     }
 346 
 347     heap->resize_all_tlabs();
 348 
 349     // We collected the heap, recalculate the metaspace capacity
 350     MetaspaceGC::compute_new_size();
 351