--- old/src/hotspot/share/memory/heapInspection.cpp 2020-04-25 22:41:19.725492892 +0800 +++ new/src/hotspot/share/memory/heapInspection.cpp 2020-04-25 22:41:19.545493694 +0800 @@ -540,6 +540,14 @@ } }; +// Heap inspection for every worker. +// When native OOM hanppens for KlassInfoTable, set _success to false. +// TODO(?) it seems atomically set/get _success is unnecessary becasue it +// is set to true at constructor and can only be set to false here. +// the only risk seems a worker may continue inspect heap when another +// worker set _success to false, but this is OK because the current worker +// doesn't change _success if everything is OK for it's inpection work, and +// the _success will be false finally and serial heap inpection can be tried. void ParHeapInspectTask::work(uint worker_id) { size_t missed_count = 0; if (!_success) { @@ -577,7 +585,10 @@ if (poi != NULL) { ParHeapInspectTask task(poi, cit, filter); Universe::heap()->run_task(&task); - return task.missed_count(); + delete poi; + if (task.success()) { + return task.missed_count(); + } } }