1 /* 2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_VM_GC_G1_G1HEAPSIZINGPOLICY_HPP 26 #define SHARE_VM_GC_G1_G1HEAPSIZINGPOLICY_HPP 27 28 #include "memory/allocation.hpp" 29 30 class G1Analytics; 31 class G1CollectedHeap; 32 33 class G1HeapSizingPolicy: public CHeapObj<mtGC> { 34 const static uint NumPrevPausesForHeuristics = 10; 35 // MinOverThresholdForGrowth must be less than NumPrevPausesForHeuristics, 36 // representing the minimum number of pause time ratios that exceed 37 // GCTimeRatio before a heap expansion will be triggered. 38 const static uint MinOverThresholdForGrowth = 4; 39 40 const G1CollectedHeap* _g1; 41 const G1Analytics* _analytics; 42 43 // Ratio check data for determining if heap growth is necessary. 44 uint _ratio_over_threshold_count; 45 double _ratio_over_threshold_sum; 46 uint _pauses_since_start; 47 48 protected: 49 G1HeapSizingPolicy(const G1CollectedHeap* g1, const G1Analytics* analytics) : 50 _g1(g1), _analytics(analytics) { 51 clear_ratio_check_data(); 52 } 53 public: 54 55 // If an expansion would be appropriate, because recent GC overhead had 56 // exceeded the desired limit, return an amount to expand by. 57 virtual size_t expansion_amount(); 58 59 // Clear ratio tracking data used by expansion_amount(). 60 void clear_ratio_check_data(); 61 62 static G1HeapSizingPolicy* create(const G1CollectedHeap* g1, const G1Analytics* analytics); 63 }; 64 65 #endif // SRC_SHARE_VM_GC_G1_G1HEAPSIZINGPOLICY_HPP