< prev index next >
src/hotspot/share/services/memTracker.cpp
Print this page
rev 55588 : imported patch 8227031-optionally-print-nmt-report-on-oom
@@ -173,10 +173,26 @@
// leads to inconsistencies unless a lot coarser locks are added.
}
return true;
}
+
+static volatile bool g_final_report_did_run = false;
+void MemTracker::final_report(outputStream* output) {
+ // This function is called during both error reporting and normal VM exit.
+ // However, it should only ever run once. E.g. if the VM crashes after
+ // printing the final report during normal VM exit, it should not print
+ // the final report again. In addition, it should be guarded from
+ // recursive calls in case NMT reporting itself crashes.
+ if (Atomic::cmpxchg(true, &g_final_report_did_run, false) == false) {
+ NMT_TrackingLevel level = tracking_level();
+ if (level >= NMT_summary) {
+ report(level == NMT_summary, output);
+ }
+ }
+}
+
void MemTracker::report(bool summary_only, outputStream* output) {
assert(output != NULL, "No output stream");
MemBaseline baseline;
if (baseline.baseline(summary_only)) {
if (summary_only) {
@@ -184,16 +200,13 @@
rpt.report();
} else {
MemDetailReporter rpt(baseline, output);
rpt.report();
output->print("Metaspace:");
- // Metadata reporting requires a safepoint, so avoid it if VM is not in good state.
- assert(!VMError::fatal_error_in_progress(), "Do not report metadata in error report");
- VM_PrintMetadata vmop(output, K,
- MetaspaceUtils::rf_show_loaders |
- MetaspaceUtils::rf_break_down_by_spacetype);
- VMThread::execute(&vmop);
+ // The basic metaspace report avoids any locking and should be safe to
+ // be called at any time.
+ MetaspaceUtils::print_basic_report(output, K);
}
}
}
// This is a walker to gather malloc site hashtable statistics,
< prev index next >