提交 c329d9fe 编写于 作者: J jmasa

8025635: SoftReferences are not cleared before metaspace OOME are thrown

Reviewed-by: jcoomes, tamao, tschatzl, stefank
上级 cffd1194
......@@ -223,9 +223,7 @@ void VM_CollectForMetadataAllocation::doit() {
_loader_data->metaspace_non_null()->expand_and_allocate(_size, _mdtype);
}
if (_result == NULL) {
// Don't clear the soft refs. This GC is for reclaiming metadata
// and is unrelated to the fullness of the Java heap which should
// be the criteria for clearing SoftReferences.
// Don't clear the soft refs yet.
if (Verbose && PrintGCDetails && UseConcMarkSweepGC) {
gclog_or_tty->print_cr("\nCMS full GC for Metaspace");
}
......@@ -235,7 +233,7 @@ void VM_CollectForMetadataAllocation::doit() {
_result =
_loader_data->metaspace_non_null()->allocate(_size, _mdtype);
}
if (_result == NULL && !UseConcMarkSweepGC /* CMS already tried */) {
if (_result == NULL) {
// If still failing, allow the Metaspace to expand.
// See delta_capacity_until_GC() for explanation of the
// amount of the expansion.
......@@ -243,7 +241,16 @@ void VM_CollectForMetadataAllocation::doit() {
// or a MaxMetaspaceSize has been specified on the command line.
_result =
_loader_data->metaspace_non_null()->expand_and_allocate(_size, _mdtype);
if (_result == NULL) {
// 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);
_result =
_loader_data->metaspace_non_null()->allocate(_size, _mdtype);
}
}
if (Verbose && PrintGCDetails && _result == NULL) {
gclog_or_tty->print_cr("\nAfter Metaspace GC failed to allocate size "
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册