< prev index next >
src/hotspot/share/gc/g1/g1YoungRemSetSamplingThread.cpp
Print this page
rev 52572 : JDK-8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
Summary: Issue optional, default enabled, concurrent cycles when the VM is idle to reclaim unused internal and Java heap memory.
Reviewed-by:
Contributed-by: Rodrigo Bruno <rbruno@gsd.inesc-id.pt>, Ruslan Synytsky <rs@jelastic.com>, Thomas Schatzl <thomas.schatzl@oracle.com>
rev 52573 : [mq]: 8212657-stefanj-review
*** 62,72 ****
// Check if enough time has passed since the last GC.
uintx time_since_last_gc;
if ((G1PeriodicGCInterval == 0) ||
((time_since_last_gc = (uintx)Universe::heap()->millis_since_last_gc()) < G1PeriodicGCInterval)) {
! log_debug(gc, periodic)("Last GC occurred " UINTX_FORMAT "ms earlier which is higher than threshold " UINTX_FORMAT "ms. Skipping.",
time_since_last_gc, G1PeriodicGCInterval);
return false;
}
// Check if load is lower than max.
--- 62,72 ----
// Check if enough time has passed since the last GC.
uintx time_since_last_gc;
if ((G1PeriodicGCInterval == 0) ||
((time_since_last_gc = (uintx)Universe::heap()->millis_since_last_gc()) < G1PeriodicGCInterval)) {
! log_debug(gc, periodic)("Last GC occurred " UINTX_FORMAT "ms before which is below threshold " UINTX_FORMAT "ms. Skipping.",
time_since_last_gc, G1PeriodicGCInterval);
return false;
}
// Check if load is lower than max.
*** 79,88 ****
--- 79,98 ----
}
return true;
}
+ void G1YoungRemSetSamplingThread::check_for_periodic_gc(){
+ if ((os::elapsedTime() - _last_periodic_gc_attempt_s) > (G1PeriodicGCInterval / 1000.0)) {
+ log_debug(gc, periodic)("Checking for periodic GC.");
+ if (should_start_periodic_gc()) {
+ Universe::heap()->collect(GCCause::_g1_periodic_collection);
+ }
+ _last_periodic_gc_attempt_s = os::elapsedTime();
+ }
+ }
+
void G1YoungRemSetSamplingThread::run_service() {
double vtime_start = os::elapsedVTime();
while (!should_terminate()) {
sample_young_list_rs_lengths();
*** 91,107 ****
_vtime_accum = (os::elapsedVTime() - vtime_start);
} else {
_vtime_accum = 0.0;
}
! if ((os::elapsedTime() - _last_periodic_gc_attempt_s) > (G1PeriodicGCInterval / 1000.0)) {
! log_debug(gc, periodic)("Checking for periodic GC.");
! if (should_start_periodic_gc()) {
! Universe::heap()->collect(GCCause::_g1_periodic_collection);
! }
! _last_periodic_gc_attempt_s = os::elapsedTime();
! }
sleep_before_next_cycle();
}
}
--- 101,111 ----
_vtime_accum = (os::elapsedVTime() - vtime_start);
} else {
_vtime_accum = 0.0;
}
! check_for_periodic_gc();
sleep_before_next_cycle();
}
}
< prev index next >