Mercurial > hg > graal-jvmci-8
annotate src/share/vm/services/memBaseline.hpp @ 20553:417e3b8d04c5
8059100: SIGSEGV VirtualMemoryTracker::remove_released_region
Summary: Disallow increasing native memory tracking level
Reviewed-by: hseigel, ctornqvi, gtriantafill
author | coleenp |
---|---|
date | Fri, 10 Oct 2014 19:36:12 +0000 |
parents | dd3939fe8424 |
children |
rev | line source |
---|---|
6197 | 1 /* |
20360 | 2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. |
6197 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
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 | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 * | |
23 */ | |
24 | |
25 #ifndef SHARE_VM_SERVICES_MEM_BASELINE_HPP | |
26 #define SHARE_VM_SERVICES_MEM_BASELINE_HPP | |
27 | |
20360 | 28 #if INCLUDE_NMT |
29 | |
6197 | 30 #include "memory/allocation.hpp" |
31 #include "runtime/mutex.hpp" | |
20360 | 32 #include "services/mallocSiteTable.hpp" |
33 #include "services/mallocTracker.hpp" | |
34 #include "services/nmtCommon.hpp" | |
35 #include "services/virtualMemoryTracker.hpp" | |
36 #include "utilities/linkedlist.hpp" | |
6197 | 37 |
20360 | 38 typedef LinkedListIterator<MallocSite> MallocSiteIterator; |
39 typedef LinkedListIterator<VirtualMemoryAllocationSite> VirtualMemorySiteIterator; | |
40 typedef LinkedListIterator<ReservedMemoryRegion> VirtualMemoryAllocationIterator; | |
6197 | 41 |
42 /* | |
20360 | 43 * Baseline a memory snapshot |
6197 | 44 */ |
20360 | 45 class MemBaseline VALUE_OBJ_CLASS_SPEC { |
6197 | 46 public: |
20360 | 47 enum BaselineThreshold { |
48 SIZE_THRESHOLD = K // Only allocation size over this threshold will be baselined. | |
49 }; | |
6197 | 50 |
20360 | 51 enum BaselineType { |
52 Not_baselined, | |
53 Summary_baselined, | |
54 Detail_baselined | |
55 }; | |
6197 | 56 |
20360 | 57 enum SortingOrder { |
58 by_address, // by memory address | |
59 by_size, // by memory size | |
60 by_site // by call site where the memory is allocated from | |
6197 | 61 }; |
62 | |
20360 | 63 private: |
64 // Summary information | |
20366 | 65 MallocMemorySnapshot _malloc_memory_snapshot; |
66 VirtualMemorySnapshot _virtual_memory_snapshot; | |
20360 | 67 |
68 size_t _class_count; | |
6197 | 69 |
20360 | 70 // Allocation sites information |
71 // Malloc allocation sites | |
20366 | 72 LinkedListImpl<MallocSite> _malloc_sites; |
20360 | 73 |
74 // All virtual memory allocations | |
20366 | 75 LinkedListImpl<ReservedMemoryRegion> _virtual_memory_allocations; |
6197 | 76 |
20360 | 77 // Virtual memory allocations by allocation sites, always in by_address |
78 // order | |
20366 | 79 LinkedListImpl<VirtualMemoryAllocationSite> _virtual_memory_sites; |
20360 | 80 |
81 SortingOrder _malloc_sites_order; | |
82 SortingOrder _virtual_memory_sites_order; | |
83 | |
84 BaselineType _baseline_type; | |
6197 | 85 |
86 public: | |
20360 | 87 // create a memory baseline |
88 MemBaseline(): | |
89 _baseline_type(Not_baselined), | |
20366 | 90 _class_count(0) { |
6197 | 91 } |
92 | |
20360 | 93 bool baseline(bool summaryOnly = true); |
6197 | 94 |
20360 | 95 BaselineType baseline_type() const { return _baseline_type; } |
6197 | 96 |
20366 | 97 MallocMemorySnapshot* malloc_memory_snapshot() { |
98 return &_malloc_memory_snapshot; | |
6197 | 99 } |
100 | |
20366 | 101 VirtualMemorySnapshot* virtual_memory_snapshot() { |
102 return &_virtual_memory_snapshot; | |
6197 | 103 } |
104 | |
20360 | 105 MallocSiteIterator malloc_sites(SortingOrder order); |
106 VirtualMemorySiteIterator virtual_memory_sites(SortingOrder order); | |
6197 | 107 |
20360 | 108 // Virtual memory allocation iterator always returns in virtual memory |
109 // base address order. | |
110 VirtualMemoryAllocationIterator virtual_memory_allocations() { | |
111 assert(!_virtual_memory_allocations.is_empty(), "Not detail baseline"); | |
112 return VirtualMemoryAllocationIterator(_virtual_memory_allocations.head()); | |
6197 | 113 } |
114 | |
20360 | 115 // Total reserved memory = total malloc'd memory + total reserved virtual |
116 // memory | |
117 size_t total_reserved_memory() const { | |
118 assert(baseline_type() != Not_baselined, "Not yet baselined"); | |
20366 | 119 size_t amount = _malloc_memory_snapshot.total() + |
120 _virtual_memory_snapshot.total_reserved(); | |
20360 | 121 return amount; |
6197 | 122 } |
123 | |
20360 | 124 // Total committed memory = total malloc'd memory + total committed |
125 // virtual memory | |
126 size_t total_committed_memory() const { | |
127 assert(baseline_type() != Not_baselined, "Not yet baselined"); | |
20366 | 128 size_t amount = _malloc_memory_snapshot.total() + |
129 _virtual_memory_snapshot.total_committed(); | |
20360 | 130 return amount; |
6197 | 131 } |
132 | |
20360 | 133 size_t total_arena_memory() const { |
134 assert(baseline_type() != Not_baselined, "Not yet baselined"); | |
20366 | 135 return _malloc_memory_snapshot.total_arena(); |
6197 | 136 } |
137 | |
20360 | 138 size_t malloc_tracking_overhead() const { |
139 assert(baseline_type() != Not_baselined, "Not yet baselined"); | |
20366 | 140 MemBaseline* bl = const_cast<MemBaseline*>(this); |
141 return bl->_malloc_memory_snapshot.malloc_overhead()->size(); | |
6197 | 142 } |
143 | |
20366 | 144 MallocMemory* malloc_memory(MEMFLAGS flag) { |
145 assert(baseline_type() != Not_baselined, "Not yet baselined"); | |
146 return _malloc_memory_snapshot.by_type(flag); | |
6197 | 147 } |
148 | |
20366 | 149 VirtualMemory* virtual_memory(MEMFLAGS flag) { |
150 assert(baseline_type() != Not_baselined, "Not yet baselined"); | |
151 return _virtual_memory_snapshot.by_type(flag); | |
6197 | 152 } |
153 | |
154 | |
20360 | 155 size_t class_count() const { |
156 assert(baseline_type() != Not_baselined, "Not yet baselined"); | |
157 return _class_count; | |
6197 | 158 } |
159 | |
20360 | 160 size_t thread_count() const { |
161 assert(baseline_type() != Not_baselined, "Not yet baselined"); | |
20366 | 162 return _malloc_memory_snapshot.thread_count(); |
6197 | 163 } |
164 | |
165 // reset the baseline for reuse | |
20360 | 166 void reset() { |
167 _baseline_type = Not_baselined; | |
20553
417e3b8d04c5
8059100: SIGSEGV VirtualMemoryTracker::remove_released_region
coleenp
parents:
20366
diff
changeset
|
168 // _malloc_memory_snapshot and _virtual_memory_snapshot are copied over. |
20360 | 169 _class_count = 0; |
6197 | 170 |
20366 | 171 _malloc_sites.clear(); |
172 _virtual_memory_sites.clear(); | |
173 _virtual_memory_allocations.clear(); | |
6197 | 174 } |
175 | |
20360 | 176 private: |
177 // Baseline summary information | |
178 bool baseline_summary(); | |
6197 | 179 |
20360 | 180 // Baseline allocation sites (detail tracking only) |
181 bool baseline_allocation_sites(); | |
182 | |
183 // Aggregate virtual memory allocation by allocation sites | |
184 bool aggregate_virtual_memory_allocation_sites(); | |
6197 | 185 |
20360 | 186 // Sorting allocation sites in different orders |
187 // Sort allocation sites in size order | |
188 void malloc_sites_to_size_order(); | |
189 // Sort allocation sites in call site address order | |
190 void malloc_sites_to_allocation_site_order(); | |
6197 | 191 |
20360 | 192 // Sort allocation sites in reserved size order |
193 void virtual_memory_sites_to_size_order(); | |
194 // Sort allocation sites in call site address order | |
195 void virtual_memory_sites_to_reservation_site_order(); | |
6197 | 196 }; |
197 | |
20360 | 198 #endif // INCLUDE_NMT |
6197 | 199 |
200 #endif // SHARE_VM_SERVICES_MEM_BASELINE_HPP |