< prev index next >
src/share/vm/gc/shared/collectedHeap.cpp
Print this page
@@ -31,10 +31,11 @@
#include "gc/shared/gcHeapSummary.hpp"
#include "gc/shared/gcTrace.hpp"
#include "gc/shared/gcTraceTime.hpp"
#include "gc/shared/gcWhen.hpp"
#include "gc/shared/vmGCOperations.hpp"
+#include "logging/log.hpp"
#include "memory/metaspace.hpp"
#include "oops/instanceMirrorKlass.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/init.hpp"
#include "runtime/thread.inline.hpp"
@@ -51,11 +52,11 @@
void EventLogBase<GCMessage>::print(outputStream* st, GCMessage& m) {
st->print_cr("GC heap %s", m.is_before ? "before" : "after");
st->print_raw(m);
}
-void GCHeapLog::log_heap(bool before) {
+void GCHeapLog::log_heap(CollectedHeap* heap, bool before) {
if (!should_log()) {
return;
}
double timestamp = fetch_timestamp();
@@ -63,15 +64,18 @@
int index = compute_log_index();
_records[index].thread = NULL; // Its the GC thread so it's not that interesting.
_records[index].timestamp = timestamp;
_records[index].data.is_before = before;
stringStream st(_records[index].data.buffer(), _records[index].data.size());
- if (before) {
- Universe::print_heap_before_gc(&st, true);
- } else {
- Universe::print_heap_after_gc(&st, true);
- }
+
+ st.print_cr("{Heap %s GC invocations=%u (full %u):",
+ before ? "before" : "after",
+ heap->total_collections(),
+ heap->total_full_collections());
+
+ heap->print_on(&st);
+ st.print_cr("}");
}
VirtualSpaceSummary CollectedHeap::create_heap_space_summary() {
size_t capacity_in_words = capacity() / HeapWordSize;
@@ -106,24 +110,20 @@
return MetaspaceSummary(MetaspaceGC::capacity_until_GC(), meta_space, data_space, class_space,
ms_chunk_free_list_summary, class_chunk_free_list_summary);
}
void CollectedHeap::print_heap_before_gc() {
- if (PrintHeapAtGC) {
Universe::print_heap_before_gc();
- }
if (_gc_heap_log != NULL) {
- _gc_heap_log->log_heap_before();
+ _gc_heap_log->log_heap_before(this);
}
}
void CollectedHeap::print_heap_after_gc() {
- if (PrintHeapAtGC) {
Universe::print_heap_after_gc();
- }
if (_gc_heap_log != NULL) {
- _gc_heap_log->log_heap_after();
+ _gc_heap_log->log_heap_after(this);
}
}
void CollectedHeap::print_on_error(outputStream* st) const {
st->print_cr("Heap:");
@@ -569,38 +569,34 @@
ThreadLocalAllocBuffer::resize_all_tlabs();
}
}
-void CollectedHeap::pre_full_gc_dump(GCTimer* timer) {
- if (HeapDumpBeforeFullGC) {
+void CollectedHeap::full_gc_dump(GCTimer* timer, const char* when) {
+ if (HeapDumpBeforeFullGC || HeapDumpAfterFullGC) {
GCIdMarkAndRestore gc_id_mark;
- GCTraceTime tt("Heap Dump (before full gc): ", PrintGCDetails, false, timer);
- // We are doing a full collection and a heap dump before
- // full collection has been requested.
+ FormatBuffer<> title("Heap Dump (%s full gc)", when);
+ GCTraceTime(Info, gc) tm(title.buffer(), timer);
HeapDumper::dump_heap();
}
- if (PrintClassHistogramBeforeFullGC) {
+ LogHandle(gc, classhisto) log;
+ if (log.is_trace()) {
+ ResourceMark rm;
GCIdMarkAndRestore gc_id_mark;
- GCTraceTime tt("Class Histogram (before full gc): ", PrintGCDetails, true, timer);
- VM_GC_HeapInspection inspector(gclog_or_tty, false /* ! full gc */);
+ FormatBuffer<> title("Class Histogram (%s full gc)", when);
+ GCTraceTime(Trace, gc, classhisto) tm(title.buffer(), timer);
+ VM_GC_HeapInspection inspector(log.trace_stream(), false /* ! full gc */);
inspector.doit();
}
}
+void CollectedHeap::pre_full_gc_dump(GCTimer* timer) {
+ full_gc_dump(timer, "before");
+}
+
void CollectedHeap::post_full_gc_dump(GCTimer* timer) {
- if (HeapDumpAfterFullGC) {
- GCIdMarkAndRestore gc_id_mark;
- GCTraceTime tt("Heap Dump (after full gc): ", PrintGCDetails, false, timer);
- HeapDumper::dump_heap();
- }
- if (PrintClassHistogramAfterFullGC) {
- GCIdMarkAndRestore gc_id_mark;
- GCTraceTime tt("Class Histogram (after full gc): ", PrintGCDetails, true, timer);
- VM_GC_HeapInspection inspector(gclog_or_tty, false /* ! full gc */);
- inspector.doit();
- }
+ full_gc_dump(timer, "after");
}
void CollectedHeap::initialize_reserved_region(HeapWord *start, HeapWord *end) {
// It is important to do this in a way such that concurrent readers can't
// temporarily think something is in the heap. (Seen this happen in asserts.)
< prev index next >