Skip to content

g1 region Max_Survivor_Regions

wangkaiwu edited this page Feb 7, 2022 · 1 revision

_max_survivor_regions

赋值

SurvivorRatio 的默认值是8

class G1Policy: public CHeapObj<mtGC> {
    uint _max_survivor_regions;
    
};
void G1Policy::update_survivors_policy() {
    double max_survivor_regions_d =
                 (double) _young_list_target_length / (double) SurvivorRatio;
    uint const desired_max_survivor_regions = ceil(max_survivor_regions_d);
    _max_survivor_regions = MIN2(desired_max_survivor_regions,
                               _g1h->num_free_or_available_regions());
}

调用过程

void G1Policy::record_collection_pause_start(double start_time_sec) {
    update_survivors_policy();
}
void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_pause_time_ms) {
    policy()->record_collection_pause_start(sample_start_time_sec);
}

Clone this wiki locally