556 // we'd just have to grow the heap up again for the next phase. So we
557 // damp the shrinking: 0% on the first call, 10% on the second call, 40%
558 // on the third call, and 100% by the fourth call. But if we recompute
559 // size without shrinking, it goes back to 0%.
560 shrink_bytes = shrink_bytes / 100 * current_shrink_factor;
561 assert(shrink_bytes <= max_shrink_bytes, "invalid shrink size");
562 if (current_shrink_factor == 0) {
563 _shrink_factor = 10;
564 } else {
565 _shrink_factor = MIN2(current_shrink_factor * 4, (size_t) 100);
566 }
567 if (PrintGC && Verbose) {
568 gclog_or_tty->print_cr(" "
569 " shrinking:"
570 " initSize: %.1fK"
571 " maximum_desired_capacity: %.1fK",
572 spec()->init_size() / (double) K,
573 maximum_desired_capacity / (double) K);
574 gclog_or_tty->print_cr(" "
575 " shrink_bytes: %.1fK"
576 " current_shrink_factor: %d"
577 " new shrink factor: %d"
578 " _min_heap_delta_bytes: %.1fK",
579 shrink_bytes / (double) K,
580 current_shrink_factor,
581 _shrink_factor,
582 _min_heap_delta_bytes / (double) K);
583 }
584 }
585 }
586
587 if (capacity_after_gc > _capacity_at_prologue) {
588 // We might have expanded for promotions, in which case we might want to
589 // take back that expansion if there's room after GC. That keeps us from
590 // stretching the heap with promotions when there's plenty of room.
591 size_t expansion_for_promotion = capacity_after_gc - _capacity_at_prologue;
592 expansion_for_promotion = MIN2(expansion_for_promotion, max_shrink_bytes);
593 // We have two shrinking computations, take the largest
594 shrink_bytes = MAX2(shrink_bytes, expansion_for_promotion);
595 assert(shrink_bytes <= max_shrink_bytes, "invalid shrink size");
596 if (PrintGC && Verbose) {
597 gclog_or_tty->print_cr(" "
|
556 // we'd just have to grow the heap up again for the next phase. So we
557 // damp the shrinking: 0% on the first call, 10% on the second call, 40%
558 // on the third call, and 100% by the fourth call. But if we recompute
559 // size without shrinking, it goes back to 0%.
560 shrink_bytes = shrink_bytes / 100 * current_shrink_factor;
561 assert(shrink_bytes <= max_shrink_bytes, "invalid shrink size");
562 if (current_shrink_factor == 0) {
563 _shrink_factor = 10;
564 } else {
565 _shrink_factor = MIN2(current_shrink_factor * 4, (size_t) 100);
566 }
567 if (PrintGC && Verbose) {
568 gclog_or_tty->print_cr(" "
569 " shrinking:"
570 " initSize: %.1fK"
571 " maximum_desired_capacity: %.1fK",
572 spec()->init_size() / (double) K,
573 maximum_desired_capacity / (double) K);
574 gclog_or_tty->print_cr(" "
575 " shrink_bytes: %.1fK"
576 " current_shrink_factor: " SIZE_FORMAT
577 " new shrink factor: " SIZE_FORMAT
578 " _min_heap_delta_bytes: %.1fK",
579 shrink_bytes / (double) K,
580 current_shrink_factor,
581 _shrink_factor,
582 _min_heap_delta_bytes / (double) K);
583 }
584 }
585 }
586
587 if (capacity_after_gc > _capacity_at_prologue) {
588 // We might have expanded for promotions, in which case we might want to
589 // take back that expansion if there's room after GC. That keeps us from
590 // stretching the heap with promotions when there's plenty of room.
591 size_t expansion_for_promotion = capacity_after_gc - _capacity_at_prologue;
592 expansion_for_promotion = MIN2(expansion_for_promotion, max_shrink_bytes);
593 // We have two shrinking computations, take the largest
594 shrink_bytes = MAX2(shrink_bytes, expansion_for_promotion);
595 assert(shrink_bytes <= max_shrink_bytes, "invalid shrink size");
596 if (PrintGC && Verbose) {
597 gclog_or_tty->print_cr(" "
|