1557 // Capacity too large, compute shrinking size
1558 shrink_bytes = capacity_until_GC - maximum_desired_capacity;
1559 // We don't want shrink all the way back to initSize if people call
1560 // System.gc(), because some programs do that between "phases" and then
1561 // we'd just have to grow the heap up again for the next phase. So we
1562 // damp the shrinking: 0% on the first call, 10% on the second call, 40%
1563 // on the third call, and 100% by the fourth call. But if we recompute
1564 // size without shrinking, it goes back to 0%.
1565 shrink_bytes = shrink_bytes / 100 * current_shrink_factor;
1566
1567 shrink_bytes = align_size_down(shrink_bytes, Metaspace::commit_alignment());
1568
1569 assert(shrink_bytes <= max_shrink_bytes,
1570 "invalid shrink size " SIZE_FORMAT " not <= " SIZE_FORMAT,
1571 shrink_bytes, max_shrink_bytes);
1572 if (current_shrink_factor == 0) {
1573 _shrink_factor = 10;
1574 } else {
1575 _shrink_factor = MIN2(current_shrink_factor * 4, (uint) 100);
1576 }
1577 log_trace(gc, metaspace)(" shrinking: initSize: %.1fK maximum_desired_capacity: %.1fK",
1578 MetaspaceSize / (double) K, maximum_desired_capacity / (double) K);
1579 log_trace(gc, metaspace)(" shrink_bytes: %.1fK current_shrink_factor: %d new shrink factor: %d MinMetaspaceExpansion: %.1fK",
1580 shrink_bytes / (double) K, current_shrink_factor, _shrink_factor, MinMetaspaceExpansion / (double) K);
1581 }
1582 }
1583
1584 // Don't shrink unless it's significant
1585 if (shrink_bytes >= MinMetaspaceExpansion &&
1586 ((capacity_until_GC - shrink_bytes) >= MetaspaceSize)) {
1587 size_t new_capacity_until_GC = MetaspaceGC::dec_capacity_until_GC(shrink_bytes);
1588 Metaspace::tracer()->report_gc_threshold(capacity_until_GC,
1589 new_capacity_until_GC,
1590 MetaspaceGCThresholdUpdater::ComputeNewSize);
1591 }
1592 }
1593
1594 // Metadebug methods
1595
1596 void Metadebug::init_allocation_fail_alot_count() {
1597 if (MetadataAllocationFailALot) {
|
1557 // Capacity too large, compute shrinking size
1558 shrink_bytes = capacity_until_GC - maximum_desired_capacity;
1559 // We don't want shrink all the way back to initSize if people call
1560 // System.gc(), because some programs do that between "phases" and then
1561 // we'd just have to grow the heap up again for the next phase. So we
1562 // damp the shrinking: 0% on the first call, 10% on the second call, 40%
1563 // on the third call, and 100% by the fourth call. But if we recompute
1564 // size without shrinking, it goes back to 0%.
1565 shrink_bytes = shrink_bytes / 100 * current_shrink_factor;
1566
1567 shrink_bytes = align_size_down(shrink_bytes, Metaspace::commit_alignment());
1568
1569 assert(shrink_bytes <= max_shrink_bytes,
1570 "invalid shrink size " SIZE_FORMAT " not <= " SIZE_FORMAT,
1571 shrink_bytes, max_shrink_bytes);
1572 if (current_shrink_factor == 0) {
1573 _shrink_factor = 10;
1574 } else {
1575 _shrink_factor = MIN2(current_shrink_factor * 4, (uint) 100);
1576 }
1577 log_trace(gc, metaspace)(" shrinking: initThreshold: %.1fK maximum_desired_capacity: %.1fK",
1578 MetaspaceSize / (double) K, maximum_desired_capacity / (double) K);
1579 log_trace(gc, metaspace)(" shrink_bytes: %.1fK current_shrink_factor: %d new shrink factor: %d MinMetaspaceExpansion: %.1fK",
1580 shrink_bytes / (double) K, current_shrink_factor, _shrink_factor, MinMetaspaceExpansion / (double) K);
1581 }
1582 }
1583
1584 // Don't shrink unless it's significant
1585 if (shrink_bytes >= MinMetaspaceExpansion &&
1586 ((capacity_until_GC - shrink_bytes) >= MetaspaceSize)) {
1587 size_t new_capacity_until_GC = MetaspaceGC::dec_capacity_until_GC(shrink_bytes);
1588 Metaspace::tracer()->report_gc_threshold(capacity_until_GC,
1589 new_capacity_until_GC,
1590 MetaspaceGCThresholdUpdater::ComputeNewSize);
1591 }
1592 }
1593
1594 // Metadebug methods
1595
1596 void Metadebug::init_allocation_fail_alot_count() {
1597 if (MetadataAllocationFailALot) {
|