179 acceptable_gc_interval, time_since_last_gc, time_until_gc);
180
181 return time_until_gc <= 0;
182 }
183
184 bool ZDirector::rule_high_usage() const {
185 // Perform GC if the amount of free memory is 5% or less. This is a preventive
186 // meassure in the case where the application has a very low allocation rate,
187 // such that the allocation rate rule doesn't trigger, but the amount of free
188 // memory is still slowly but surely heading towards zero. In this situation,
189 // we start a GC cycle to avoid a potential allocation stall later.
190
191 // Calculate amount of free memory available to Java threads. Note that
192 // the heap reserve is not available to Java threads and is therefore not
193 // considered part of the free memory.
194 const size_t max_capacity = ZHeap::heap()->current_max_capacity();
195 const size_t max_reserve = ZHeap::heap()->max_reserve();
196 const size_t used = ZHeap::heap()->used();
197 const size_t free_with_reserve = max_capacity - used;
198 const size_t free = free_with_reserve - MIN2(free_with_reserve, max_reserve);
199
200 return percent_of(free, max_capacity) <= 5.0;
201 }
202
203 GCCause::Cause ZDirector::make_gc_decision() const {
204 // Rule 0: Timer
205 if (rule_timer()) {
206 return GCCause::_z_timer;
207 }
208
209 // Rule 1: Warmup
210 if (rule_warmup()) {
211 return GCCause::_z_warmup;
212 }
213
214 // Rule 2: Allocation rate
215 if (rule_allocation_rate()) {
216 return GCCause::_z_allocation_rate;
217 }
218
219 // Rule 3: Proactive
220 if (rule_proactive()) {
|
179 acceptable_gc_interval, time_since_last_gc, time_until_gc);
180
181 return time_until_gc <= 0;
182 }
183
184 bool ZDirector::rule_high_usage() const {
185 // Perform GC if the amount of free memory is 5% or less. This is a preventive
186 // meassure in the case where the application has a very low allocation rate,
187 // such that the allocation rate rule doesn't trigger, but the amount of free
188 // memory is still slowly but surely heading towards zero. In this situation,
189 // we start a GC cycle to avoid a potential allocation stall later.
190
191 // Calculate amount of free memory available to Java threads. Note that
192 // the heap reserve is not available to Java threads and is therefore not
193 // considered part of the free memory.
194 const size_t max_capacity = ZHeap::heap()->current_max_capacity();
195 const size_t max_reserve = ZHeap::heap()->max_reserve();
196 const size_t used = ZHeap::heap()->used();
197 const size_t free_with_reserve = max_capacity - used;
198 const size_t free = free_with_reserve - MIN2(free_with_reserve, max_reserve);
199 const double free_percent = percent_of(free, max_capacity);
200
201 log_debug(gc, director)("Rule: High Usage, Free: " SIZE_FORMAT "MB(%.1lf%%)",
202 free / M, free_percent);
203
204 return free_percent <= 5.0;
205 }
206
207 GCCause::Cause ZDirector::make_gc_decision() const {
208 // Rule 0: Timer
209 if (rule_timer()) {
210 return GCCause::_z_timer;
211 }
212
213 // Rule 1: Warmup
214 if (rule_warmup()) {
215 return GCCause::_z_warmup;
216 }
217
218 // Rule 2: Allocation rate
219 if (rule_allocation_rate()) {
220 return GCCause::_z_allocation_rate;
221 }
222
223 // Rule 3: Proactive
224 if (rule_proactive()) {
|