218 // If this was the requested GC cycle, notify waiters about it
219 if (explicit_gc_requested || implicit_gc_requested) {
220 notify_gc_waiters();
221 }
222
223 // If this was the allocation failure GC cycle, notify waiters about it
224 if (alloc_failure_pending) {
225 notify_alloc_failure_waiters();
226 }
227
228 // Report current free set state at the end of cycle, whether
229 // it is a normal completion, or the abort.
230 {
231 ShenandoahHeapLocker locker(heap->lock());
232 heap->free_set()->log_status();
233
234 // Notify Universe about new heap usage. This has implications for
235 // global soft refs policy, and we better report it every time heap
236 // usage goes down.
237 Universe::update_heap_info_at_gc();
238 }
239
240 // Disable forced counters update, and update counters one more time
241 // to capture the state at the end of GC session.
242 handle_force_counters_update();
243 set_forced_counters_update(false);
244
245 // Retract forceful part of soft refs policy
246 heap->soft_ref_policy()->set_should_clear_all_soft_refs(false);
247
248 // Clear metaspace oom flag, if current cycle unloaded classes
249 if (heap->unload_classes()) {
250 heuristics->clear_metaspace_oom();
251 }
252
253 // Commit worker statistics to cycle data
254 heap->phase_timings()->flush_par_workers_to_cycle();
255 if (ShenandoahPacing) {
256 heap->pacer()->flush_stats_to_cycle();
257 }
258
259 // Print GC stats for current cycle
260 {
261 LogTarget(Info, gc, stats) lt;
262 if (lt.is_enabled()) {
263 ResourceMark rm;
264 LogStream ls(lt);
265 heap->phase_timings()->print_cycle_on(&ls);
266 if (ShenandoahPacing) {
267 heap->pacer()->print_cycle_on(&ls);
268 }
269 }
270 }
271
272 // Commit statistics to globals
273 heap->phase_timings()->flush_cycle_to_global();
274
275 // Print Metaspace change following GC (if logging is enabled).
276 MetaspaceUtils::print_metaspace_change(meta_sizes);
277
278 heap->next_whole_heap_examined();
279
280 // GC is over, we are at idle now
281 if (ShenandoahPacing) {
282 heap->pacer()->setup_for_idle();
283 }
284 } else {
285 // Allow allocators to know we have seen this much regions
286 if (ShenandoahPacing && (allocs_seen > 0)) {
287 heap->pacer()->report_alloc(allocs_seen);
288 }
289 }
290
291 double current = os::elapsedTime();
292
293 if (ShenandoahUncommit && (explicit_gc_requested || (current - last_shrink_time > shrink_period))) {
294 // Try to uncommit enough stale regions. Explicit GC tries to uncommit everything.
295 // Regular paths uncommit only occasionally.
296 double shrink_before = explicit_gc_requested ?
297 current :
298 current - (ShenandoahUncommitDelay / 1000.0);
|
218 // If this was the requested GC cycle, notify waiters about it
219 if (explicit_gc_requested || implicit_gc_requested) {
220 notify_gc_waiters();
221 }
222
223 // If this was the allocation failure GC cycle, notify waiters about it
224 if (alloc_failure_pending) {
225 notify_alloc_failure_waiters();
226 }
227
228 // Report current free set state at the end of cycle, whether
229 // it is a normal completion, or the abort.
230 {
231 ShenandoahHeapLocker locker(heap->lock());
232 heap->free_set()->log_status();
233
234 // Notify Universe about new heap usage. This has implications for
235 // global soft refs policy, and we better report it every time heap
236 // usage goes down.
237 Universe::update_heap_info_at_gc();
238
239 // Signal that we have completed a visit to all live objects.
240 Universe::heap()->next_whole_heap_examined();
241 }
242
243 // Disable forced counters update, and update counters one more time
244 // to capture the state at the end of GC session.
245 handle_force_counters_update();
246 set_forced_counters_update(false);
247
248 // Retract forceful part of soft refs policy
249 heap->soft_ref_policy()->set_should_clear_all_soft_refs(false);
250
251 // Clear metaspace oom flag, if current cycle unloaded classes
252 if (heap->unload_classes()) {
253 heuristics->clear_metaspace_oom();
254 }
255
256 // Commit worker statistics to cycle data
257 heap->phase_timings()->flush_par_workers_to_cycle();
258 if (ShenandoahPacing) {
259 heap->pacer()->flush_stats_to_cycle();
260 }
261
262 // Print GC stats for current cycle
263 {
264 LogTarget(Info, gc, stats) lt;
265 if (lt.is_enabled()) {
266 ResourceMark rm;
267 LogStream ls(lt);
268 heap->phase_timings()->print_cycle_on(&ls);
269 if (ShenandoahPacing) {
270 heap->pacer()->print_cycle_on(&ls);
271 }
272 }
273 }
274
275 // Commit statistics to globals
276 heap->phase_timings()->flush_cycle_to_global();
277
278 // Print Metaspace change following GC (if logging is enabled).
279 MetaspaceUtils::print_metaspace_change(meta_sizes);
280
281 // GC is over, we are at idle now
282 if (ShenandoahPacing) {
283 heap->pacer()->setup_for_idle();
284 }
285 } else {
286 // Allow allocators to know we have seen this much regions
287 if (ShenandoahPacing && (allocs_seen > 0)) {
288 heap->pacer()->report_alloc(allocs_seen);
289 }
290 }
291
292 double current = os::elapsedTime();
293
294 if (ShenandoahUncommit && (explicit_gc_requested || (current - last_shrink_time > shrink_period))) {
295 // Try to uncommit enough stale regions. Explicit GC tries to uncommit everything.
296 // Regular paths uncommit only occasionally.
297 double shrink_before = explicit_gc_requested ?
298 current :
299 current - (ShenandoahUncommitDelay / 1000.0);
|