comparison src/share/vm/gc_interface/collectedHeap.cpp @ 4872:aa3d708d67c4

7141200: log some interesting information in ring buffers for crashes Reviewed-by: kvn, jrose, kevinw, brutisso, twisti, jmasa
author never
date Wed, 01 Feb 2012 07:59:01 -0800
parents b6a04c79ccbc
children 09d00c18e323
comparison
equal deleted inserted replaced
4871:f067b4e0e04b 4872:aa3d708d67c4
1 /* 1 /*
2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
49 int CollectedHeap::_fire_out_of_memory_count = 0; 49 int CollectedHeap::_fire_out_of_memory_count = 0;
50 #endif 50 #endif
51 51
52 size_t CollectedHeap::_filler_array_max_size = 0; 52 size_t CollectedHeap::_filler_array_max_size = 0;
53 53
54 template <>
55 void EventLogBase<GCMessage>::print(outputStream* st, GCMessage& m) {
56 st->print_cr("GC heap %s", m.is_before ? "before" : "after");
57 st->print_raw(m);
58 }
59
60 void GCHeapLog::log_heap(bool before) {
61 if (!should_log()) {
62 return;
63 }
64
65 jlong timestamp = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
66 MutexLockerEx ml(&_mutex, Mutex::_no_safepoint_check_flag);
67 int index = compute_log_index();
68 _records[index].thread = NULL; // Its the GC thread so it's not that interesting.
69 _records[index].timestamp = timestamp;
70 _records[index].data.is_before = before;
71 stringStream st(_records[index].data.buffer(), _records[index].data.size());
72 if (before) {
73 Universe::print_heap_before_gc(&st);
74 } else {
75 Universe::print_heap_after_gc(&st);
76 }
77 }
78
54 // Memory state functions. 79 // Memory state functions.
55 80
56 81
57 CollectedHeap::CollectedHeap() : _n_par_threads(0) 82 CollectedHeap::CollectedHeap() : _n_par_threads(0)
58 83
79 _perf_gc_lastcause = 104 _perf_gc_lastcause =
80 PerfDataManager::create_string_variable(SUN_GC, "lastCause", 105 PerfDataManager::create_string_variable(SUN_GC, "lastCause",
81 80, GCCause::to_string(_gc_lastcause), CHECK); 106 80, GCCause::to_string(_gc_lastcause), CHECK);
82 } 107 }
83 _defer_initial_card_mark = false; // strengthened by subclass in pre_initialize() below. 108 _defer_initial_card_mark = false; // strengthened by subclass in pre_initialize() below.
109 // Create the ring log
110 if (LogEvents) {
111 _gc_heap_log = new GCHeapLog();
112 } else {
113 _gc_heap_log = NULL;
114 }
84 } 115 }
85 116
86 void CollectedHeap::pre_initialize() { 117 void CollectedHeap::pre_initialize() {
87 // Used for ReduceInitialCardMarks (when COMPILER2 is used); 118 // Used for ReduceInitialCardMarks (when COMPILER2 is used);
88 // otherwise remains unused. 119 // otherwise remains unused.