src/share/vm/gc_implementation/shared/vmGCOperations.cpp

Print this page
rev 6671 : 8049831: Metadata Full GCs are not triggered when CMSClassUnloadingEnabled is turned off


 180   GenCollectedHeap* gch = GenCollectedHeap::heap();
 181   GCCauseSetter gccs(gch, _gc_cause);
 182   _res = gch->satisfy_failed_allocation(_size, _tlab);
 183   assert(gch->is_in_reserved_or_null(_res), "result not in heap");
 184 
 185   if (_res == NULL && GC_locker::is_active_and_needs_gc()) {
 186     set_gc_locked();
 187   }
 188 }
 189 
 190 void VM_GenCollectFull::doit() {
 191   SvcGCMarker sgcm(SvcGCMarker::FULL);
 192 
 193   GenCollectedHeap* gch = GenCollectedHeap::heap();
 194   GCCauseSetter gccs(gch, _gc_cause);
 195   gch->do_full_collection(gch->must_clear_all_soft_refs(), _max_level);
 196 }
 197 
 198 bool VM_CollectForMetadataAllocation::initiate_concurrent_GC() {
 199 #if INCLUDE_ALL_GCS
 200   if (UseConcMarkSweepGC || UseG1GC) {
 201     if (UseConcMarkSweepGC && CMSClassUnloadingEnabled) {
 202       MetaspaceGC::set_should_concurrent_collect(true);
 203     } else if (UseG1GC) {



 204       G1CollectedHeap* g1h = G1CollectedHeap::heap();
 205       g1h->g1_policy()->set_initiate_conc_mark_if_possible();
 206 
 207       GCCauseSetter x(g1h, _gc_cause);
 208 
 209       // At this point we are supposed to start a concurrent cycle. We
 210       // will do so if one is not already in progress.
 211       bool should_start = g1h->g1_policy()->force_initial_mark_if_outside_cycle(_gc_cause);
 212 
 213       if (should_start) {
 214         double pause_target = g1h->g1_policy()->max_pause_time_ms();
 215         g1h->do_collection_pause_at_safepoint(pause_target);
 216       }
 217     }
 218 
 219     return true;
 220   }
 221 #endif

 222   return false;
 223 }
 224 
 225 static void log_metaspace_alloc_failure_for_concurrent_GC() {
 226   if (Verbose && PrintGCDetails) {
 227     if (UseConcMarkSweepGC) {
 228       gclog_or_tty->print_cr("\nCMS full GC for Metaspace");
 229     } else if (UseG1GC) {
 230       gclog_or_tty->print_cr("\nG1 full GC for Metaspace");
 231     }
 232   }
 233 }
 234 
 235 void VM_CollectForMetadataAllocation::doit() {
 236   SvcGCMarker sgcm(SvcGCMarker::FULL);
 237 
 238   CollectedHeap* heap = Universe::heap();
 239   GCCauseSetter gccs(heap, _gc_cause);
 240 
 241   // Check again if the space is available.  Another thread




 180   GenCollectedHeap* gch = GenCollectedHeap::heap();
 181   GCCauseSetter gccs(gch, _gc_cause);
 182   _res = gch->satisfy_failed_allocation(_size, _tlab);
 183   assert(gch->is_in_reserved_or_null(_res), "result not in heap");
 184 
 185   if (_res == NULL && GC_locker::is_active_and_needs_gc()) {
 186     set_gc_locked();
 187   }
 188 }
 189 
 190 void VM_GenCollectFull::doit() {
 191   SvcGCMarker sgcm(SvcGCMarker::FULL);
 192 
 193   GenCollectedHeap* gch = GenCollectedHeap::heap();
 194   GCCauseSetter gccs(gch, _gc_cause);
 195   gch->do_full_collection(gch->must_clear_all_soft_refs(), _max_level);
 196 }
 197 
 198 bool VM_CollectForMetadataAllocation::initiate_concurrent_GC() {
 199 #if INCLUDE_ALL_GCS

 200   if (UseConcMarkSweepGC && CMSClassUnloadingEnabled) {
 201     MetaspaceGC::set_should_concurrent_collect(true);
 202     return true;
 203   }
 204 
 205   if (UseG1GC) {
 206     G1CollectedHeap* g1h = G1CollectedHeap::heap();
 207     g1h->g1_policy()->set_initiate_conc_mark_if_possible();
 208 
 209     GCCauseSetter x(g1h, _gc_cause);
 210 
 211     // At this point we are supposed to start a concurrent cycle. We
 212     // will do so if one is not already in progress.
 213     bool should_start = g1h->g1_policy()->force_initial_mark_if_outside_cycle(_gc_cause);
 214 
 215     if (should_start) {
 216       double pause_target = g1h->g1_policy()->max_pause_time_ms();
 217       g1h->do_collection_pause_at_safepoint(pause_target);
 218     }


 219     return true;
 220   }
 221 #endif
 222 
 223   return false;
 224 }
 225 
 226 static void log_metaspace_alloc_failure_for_concurrent_GC() {
 227   if (Verbose && PrintGCDetails) {
 228     if (UseConcMarkSweepGC) {
 229       gclog_or_tty->print_cr("\nCMS full GC for Metaspace");
 230     } else if (UseG1GC) {
 231       gclog_or_tty->print_cr("\nG1 full GC for Metaspace");
 232     }
 233   }
 234 }
 235 
 236 void VM_CollectForMetadataAllocation::doit() {
 237   SvcGCMarker sgcm(SvcGCMarker::FULL);
 238 
 239   CollectedHeap* heap = Universe::heap();
 240   GCCauseSetter gccs(heap, _gc_cause);
 241 
 242   // Check again if the space is available.  Another thread