--- old/src/share/vm/gc/g1/g1Analytics.hpp 2016-03-17 13:51:02.927280475 +0100 +++ new/src/share/vm/gc/g1/g1Analytics.hpp 2016-03-17 13:51:02.839276849 +0100 @@ -88,6 +88,10 @@ return _last_pause_time_ratio; } + uint number_of_recorded_pause_times() const { + return NumPrevPausesForHeuristics; + } + void append_prev_collection_pause_end_ms(double ms) { _prev_collection_pause_end_ms += ms; } --- old/src/share/vm/gc/g1/g1HeapSizingPolicy.cpp 2016-03-17 13:51:03.395299759 +0100 +++ new/src/share/vm/gc/g1/g1HeapSizingPolicy.cpp 2016-03-17 13:51:03.307296133 +0100 @@ -68,7 +68,7 @@ // reached the end of the history buffer and the average of all entries // is still over the threshold. This indicates a smaller number of GCs were // long enough to make the average exceed the threshold. - bool filled_history_buffer = _pauses_since_start == NumPrevPausesForHeuristics; + bool filled_history_buffer = _pauses_since_start == _num_prev_pauses_for_heuristics; if ((_ratio_over_threshold_count == MinOverThresholdForGrowth) || (filled_history_buffer && (recent_gc_overhead > threshold))) { size_t min_expand_bytes = HeapRegion::GrainBytes; @@ -138,7 +138,7 @@ // start again the next time we see a ratio above the threshold. if (_ratio_over_threshold_count > 0) { _pauses_since_start++; - if (_pauses_since_start > NumPrevPausesForHeuristics) { + if (_pauses_since_start > _num_prev_pauses_for_heuristics) { clear_ratio_check_data(); } } --- old/src/share/vm/gc/g1/g1HeapSizingPolicy.hpp 2016-03-17 13:51:03.867319208 +0100 +++ new/src/share/vm/gc/g1/g1HeapSizingPolicy.hpp 2016-03-17 13:51:03.779315581 +0100 @@ -31,23 +31,26 @@ class G1CollectedHeap; class G1HeapSizingPolicy: public CHeapObj { - const static uint NumPrevPausesForHeuristics = 10; - // MinOverThresholdForGrowth must be less than NumPrevPausesForHeuristics, - // representing the minimum number of pause time ratios that exceed - // GCTimeRatio before a heap expansion will be triggered. + // MinOverThresholdForGrowth must be less than the number of recorded + // pause times in G1Analytics, representing the minimum number of pause + // time ratios that exceed GCTimeRatio before a heap expansion will be triggered. const static uint MinOverThresholdForGrowth = 4; const G1CollectedHeap* _g1; const G1Analytics* _analytics; + const uint _num_prev_pauses_for_heuristics; // Ratio check data for determining if heap growth is necessary. uint _ratio_over_threshold_count; double _ratio_over_threshold_sum; uint _pauses_since_start; + protected: G1HeapSizingPolicy(const G1CollectedHeap* g1, const G1Analytics* analytics) : - _g1(g1), _analytics(analytics) { + _g1(g1), + _analytics(analytics), + _num_prev_pauses_for_heuristics(analytics->number_of_recorded_pause_times()) { clear_ratio_check_data(); } public: