8152113: Remove _last_ditch_collection GC-cause and avoid expanding heap on Metaspace OOM
Reviewed-by: brutisso, jwilhelm
This commit is contained in:
parent
0fed01a8ec
commit
77de5508e9
@ -37,6 +37,7 @@ public enum GCCause {
|
||||
_heap_dump ("Heap Dump Initiated GC"),
|
||||
_wb_young_gc ("WhiteBox Initiated Young GC"),
|
||||
_wb_conc_mark ("WhiteBox Initiated Concurrent Mark"),
|
||||
_wb_full_gc ("WhiteBox Initiated Full GC"),
|
||||
_update_allocation_context_stats_inc ("Update Allocation Context Stats"),
|
||||
_update_allocation_context_stats_full ("Update Allocation Context Stats"),
|
||||
|
||||
@ -46,6 +47,7 @@ public enum GCCause {
|
||||
|
||||
_tenured_generation_full ("Tenured Generation Full"),
|
||||
_metadata_GC_threshold ("Metadata GC Threshold"),
|
||||
_metadata_GC_clear_soft_refs ("Metadata GC Clear Soft References"),
|
||||
|
||||
_cms_generation_full ("CMS Generation Full"),
|
||||
_cms_initial_mark ("CMS Initial Mark"),
|
||||
@ -59,8 +61,6 @@ public enum GCCause {
|
||||
_g1_inc_collection_pause ("G1 Evacuation Pause"),
|
||||
_g1_humongous_allocation ("G1 Humongous Allocation"),
|
||||
|
||||
_last_ditch_collection ("Last ditch collection"),
|
||||
|
||||
_dcmd_gc_run ("Diagnostic Command"),
|
||||
|
||||
_last_gc_cause ("ILLEGAL VALUE - last gc cause - ILLEGAL VALUE");
|
||||
|
@ -213,7 +213,7 @@ void CollectedHeap::collect_as_vm_thread(GCCause::Cause cause) {
|
||||
do_full_collection(false); // don't clear all soft refs
|
||||
break;
|
||||
}
|
||||
case GCCause::_last_ditch_collection: {
|
||||
case GCCause::_metadata_GC_clear_soft_refs: {
|
||||
HandleMark hm;
|
||||
do_full_collection(true); // do clear all soft refs
|
||||
break;
|
||||
|
@ -57,6 +57,9 @@ const char* GCCause::to_string(GCCause::Cause cause) {
|
||||
case _wb_conc_mark:
|
||||
return "WhiteBox Initiated Concurrent Mark";
|
||||
|
||||
case _wb_full_gc:
|
||||
return "WhiteBox Initiated Full GC";
|
||||
|
||||
case _update_allocation_context_stats_inc:
|
||||
case _update_allocation_context_stats_full:
|
||||
return "Update Allocation Context Stats";
|
||||
@ -73,6 +76,9 @@ const char* GCCause::to_string(GCCause::Cause cause) {
|
||||
case _metadata_GC_threshold:
|
||||
return "Metadata GC Threshold";
|
||||
|
||||
case _metadata_GC_clear_soft_refs:
|
||||
return "Metadata GC Clear Soft References";
|
||||
|
||||
case _cms_generation_full:
|
||||
return "CMS Generation Full";
|
||||
|
||||
@ -100,9 +106,6 @@ const char* GCCause::to_string(GCCause::Cause cause) {
|
||||
case _g1_humongous_allocation:
|
||||
return "G1 Humongous Allocation";
|
||||
|
||||
case _last_ditch_collection:
|
||||
return "Last ditch collection";
|
||||
|
||||
case _dcmd_gc_run:
|
||||
return "Diagnostic Command";
|
||||
|
||||
|
@ -51,6 +51,7 @@ class GCCause : public AllStatic {
|
||||
_heap_dump,
|
||||
_wb_young_gc,
|
||||
_wb_conc_mark,
|
||||
_wb_full_gc,
|
||||
_update_allocation_context_stats_inc,
|
||||
_update_allocation_context_stats_full,
|
||||
|
||||
@ -63,6 +64,7 @@ class GCCause : public AllStatic {
|
||||
|
||||
_tenured_generation_full,
|
||||
_metadata_GC_threshold,
|
||||
_metadata_GC_clear_soft_refs,
|
||||
|
||||
_cms_generation_full,
|
||||
_cms_initial_mark,
|
||||
@ -76,8 +78,6 @@ class GCCause : public AllStatic {
|
||||
_g1_inc_collection_pause,
|
||||
_g1_humongous_allocation,
|
||||
|
||||
_last_ditch_collection,
|
||||
|
||||
_dcmd_gc_run,
|
||||
|
||||
_last_gc_cause
|
||||
@ -106,22 +106,18 @@ class GCCause : public AllStatic {
|
||||
// _allocation_failure is the generic cause a collection which could result
|
||||
// in the collection of the tenured generation if there is not enough space
|
||||
// in the tenured generation to support a young GC.
|
||||
// _last_ditch_collection is a collection done to include SoftReferences.
|
||||
return (cause == GCCause::_tenured_generation_full ||
|
||||
cause == GCCause::_cms_generation_full ||
|
||||
cause == GCCause::_adaptive_size_policy ||
|
||||
cause == GCCause::_allocation_failure ||
|
||||
cause == GCCause::_last_ditch_collection);
|
||||
cause == GCCause::_allocation_failure);
|
||||
}
|
||||
|
||||
// Causes for collection of the young generation
|
||||
inline static bool is_allocation_failure_gc(GCCause::Cause cause) {
|
||||
// _allocation_failure is the generic cause a collection for allocation failure
|
||||
// _adaptive_size_policy is for a collecton done before a full GC
|
||||
// _last_ditch_collection is a collection done to include SoftReferences.
|
||||
return (cause == GCCause::_allocation_failure ||
|
||||
cause == GCCause::_adaptive_size_policy ||
|
||||
cause == GCCause::_last_ditch_collection);
|
||||
cause == GCCause::_adaptive_size_policy);
|
||||
}
|
||||
|
||||
// Return a string describing the GCCause.
|
||||
|
@ -295,7 +295,8 @@ HeapWord* GenCollectedHeap::mem_allocate(size_t size,
|
||||
}
|
||||
|
||||
bool GenCollectedHeap::must_clear_all_soft_refs() {
|
||||
return _gc_cause == GCCause::_last_ditch_collection;
|
||||
return _gc_cause == GCCause::_metadata_GC_clear_soft_refs ||
|
||||
_gc_cause == GCCause::_wb_full_gc;
|
||||
}
|
||||
|
||||
bool GenCollectedHeap::should_do_concurrent_full_gc(GCCause::Cause cause) {
|
||||
|
@ -271,12 +271,8 @@ void VM_CollectForMetadataAllocation::doit() {
|
||||
return;
|
||||
}
|
||||
|
||||
// If expansion failed, do a last-ditch collection and try allocating
|
||||
// again. A last-ditch collection will clear softrefs. This
|
||||
// behavior is similar to the last-ditch collection done for perm
|
||||
// gen when it was full and a collection for failed allocation
|
||||
// did not free perm gen space.
|
||||
heap->collect_as_vm_thread(GCCause::_last_ditch_collection);
|
||||
// If expansion failed, do a collection clearing soft references.
|
||||
heap->collect_as_vm_thread(GCCause::_metadata_GC_clear_soft_refs);
|
||||
_result = _loader_data->metaspace_non_null()->allocate(_size, _mdtype);
|
||||
if (_result != NULL) {
|
||||
return;
|
||||
|
@ -987,7 +987,7 @@ WB_END
|
||||
|
||||
WB_ENTRY(void, WB_FullGC(JNIEnv* env, jobject o))
|
||||
Universe::heap()->collector_policy()->set_should_clear_all_soft_refs(true);
|
||||
Universe::heap()->collect(GCCause::_last_ditch_collection);
|
||||
Universe::heap()->collect(GCCause::_wb_full_gc);
|
||||
#if INCLUDE_ALL_GCS
|
||||
if (UseG1GC) {
|
||||
// Needs to be cleared explicitly for G1
|
||||
|
Loading…
Reference in New Issue
Block a user