author | zgu |
Tue, 26 Mar 2019 15:50:34 -0400 | |
changeset 54292 | c31faeacf00a |
parent 53709 | 2b64ebacce93 |
child 58063 | bdf136b8ae0e |
permissions | -rw-r--r-- |
13195 | 1 |
/* |
53685
df83034c9275
8218558: NMT stack traces in output should show mt component for virtual memory allocations
zgu
parents:
49980
diff
changeset
|
2 |
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. |
13195 | 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 |
#include "precompiled.hpp" |
|
25946 | 25 |
|
26 |
#include "memory/allocation.hpp" |
|
27 |
#include "services/mallocTracker.hpp" |
|
13195 | 28 |
#include "services/memReporter.hpp" |
54292
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
29 |
#include "services/threadStackTracker.hpp" |
25946 | 30 |
#include "services/virtualMemoryTracker.hpp" |
31 |
#include "utilities/globalDefinitions.hpp" |
|
32 |
||
33 |
size_t MemReporterBase::reserved_total(const MallocMemory* malloc, const VirtualMemory* vm) const { |
|
34 |
return malloc->malloc_size() + malloc->arena_size() + vm->reserved(); |
|
35 |
} |
|
36 |
||
37 |
size_t MemReporterBase::committed_total(const MallocMemory* malloc, const VirtualMemory* vm) const { |
|
38 |
return malloc->malloc_size() + malloc->arena_size() + vm->committed(); |
|
39 |
} |
|
13195 | 40 |
|
25946 | 41 |
void MemReporterBase::print_total(size_t reserved, size_t committed) const { |
42 |
const char* scale = current_scale(); |
|
43 |
output()->print("reserved=" SIZE_FORMAT "%s, committed=" SIZE_FORMAT "%s", |
|
44 |
amount_in_current_scale(reserved), scale, amount_in_current_scale(committed), scale); |
|
45 |
} |
|
46 |
||
46489
40abcea5a9d5
8139673: NMT stack traces in output should show mtcomponent
zgu
parents:
25946
diff
changeset
|
47 |
void MemReporterBase::print_malloc(size_t amount, size_t count, MEMFLAGS flag) const { |
25946 | 48 |
const char* scale = current_scale(); |
49 |
outputStream* out = output(); |
|
54292
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
50 |
const char* alloc_type = (flag == mtThreadStack) ? "" : "malloc="; |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
51 |
|
46489
40abcea5a9d5
8139673: NMT stack traces in output should show mtcomponent
zgu
parents:
25946
diff
changeset
|
52 |
if (flag != mtNone) { |
54292
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
53 |
out->print("(%s" SIZE_FORMAT "%s type=%s", alloc_type, |
46489
40abcea5a9d5
8139673: NMT stack traces in output should show mtcomponent
zgu
parents:
25946
diff
changeset
|
54 |
amount_in_current_scale(amount), scale, NMTUtil::flag_to_name(flag)); |
40abcea5a9d5
8139673: NMT stack traces in output should show mtcomponent
zgu
parents:
25946
diff
changeset
|
55 |
} else { |
54292
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
56 |
out->print("(%s" SIZE_FORMAT "%s", alloc_type, |
46489
40abcea5a9d5
8139673: NMT stack traces in output should show mtcomponent
zgu
parents:
25946
diff
changeset
|
57 |
amount_in_current_scale(amount), scale); |
40abcea5a9d5
8139673: NMT stack traces in output should show mtcomponent
zgu
parents:
25946
diff
changeset
|
58 |
} |
25946 | 59 |
|
60 |
if (count > 0) { |
|
61 |
out->print(" #" SIZE_FORMAT "", count); |
|
62 |
} |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
22234
diff
changeset
|
63 |
|
25946 | 64 |
out->print(")"); |
65 |
} |
|
66 |
||
67 |
void MemReporterBase::print_virtual_memory(size_t reserved, size_t committed) const { |
|
68 |
const char* scale = current_scale(); |
|
69 |
output()->print("(mmap: reserved=" SIZE_FORMAT "%s, committed=" SIZE_FORMAT "%s)", |
|
70 |
amount_in_current_scale(reserved), scale, amount_in_current_scale(committed), scale); |
|
71 |
} |
|
72 |
||
73 |
void MemReporterBase::print_malloc_line(size_t amount, size_t count) const { |
|
74 |
output()->print("%28s", " "); |
|
75 |
print_malloc(amount, count); |
|
76 |
output()->print_cr(" "); |
|
77 |
} |
|
78 |
||
79 |
void MemReporterBase::print_virtual_memory_line(size_t reserved, size_t committed) const { |
|
80 |
output()->print("%28s", " "); |
|
81 |
print_virtual_memory(reserved, committed); |
|
82 |
output()->print_cr(" "); |
|
83 |
} |
|
84 |
||
85 |
void MemReporterBase::print_arena_line(size_t amount, size_t count) const { |
|
86 |
const char* scale = current_scale(); |
|
87 |
output()->print_cr("%27s (arena=" SIZE_FORMAT "%s #" SIZE_FORMAT ")", " ", |
|
88 |
amount_in_current_scale(amount), scale, count); |
|
89 |
} |
|
90 |
||
91 |
void MemReporterBase::print_virtual_memory_region(const char* type, address base, size_t size) const { |
|
92 |
const char* scale = current_scale(); |
|
93 |
output()->print("[" PTR_FORMAT " - " PTR_FORMAT "] %s " SIZE_FORMAT "%s", |
|
94 |
p2i(base), p2i(base + size), type, amount_in_current_scale(size), scale); |
|
13195 | 95 |
} |
96 |
||
97 |
||
25946 | 98 |
void MemSummaryReporter::report() { |
99 |
const char* scale = current_scale(); |
|
100 |
outputStream* out = output(); |
|
101 |
size_t total_reserved_amount = _malloc_snapshot->total() + |
|
102 |
_vm_snapshot->total_reserved(); |
|
103 |
size_t total_committed_amount = _malloc_snapshot->total() + |
|
104 |
_vm_snapshot->total_committed(); |
|
13195 | 105 |
|
25946 | 106 |
// Overall total |
107 |
out->print_cr("\nNative Memory Tracking:\n"); |
|
108 |
out->print("Total: "); |
|
109 |
print_total(total_reserved_amount, total_committed_amount); |
|
110 |
out->print("\n"); |
|
13195 | 111 |
|
25946 | 112 |
// Summary by memory type |
113 |
for (int index = 0; index < mt_number_of_types; index ++) { |
|
114 |
MEMFLAGS flag = NMTUtil::index_to_flag(index); |
|
115 |
// thread stack is reported as part of thread category |
|
116 |
if (flag == mtThreadStack) continue; |
|
117 |
MallocMemory* malloc_memory = _malloc_snapshot->by_type(flag); |
|
118 |
VirtualMemory* virtual_memory = _vm_snapshot->by_type(flag); |
|
119 |
||
120 |
report_summary_of_type(flag, malloc_memory, virtual_memory); |
|
14120
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13195
diff
changeset
|
121 |
} |
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13195
diff
changeset
|
122 |
} |
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13195
diff
changeset
|
123 |
|
25946 | 124 |
void MemSummaryReporter::report_summary_of_type(MEMFLAGS flag, |
125 |
MallocMemory* malloc_memory, VirtualMemory* virtual_memory) { |
|
13195 | 126 |
|
25946 | 127 |
size_t reserved_amount = reserved_total (malloc_memory, virtual_memory); |
128 |
size_t committed_amount = committed_total(malloc_memory, virtual_memory); |
|
13195 | 129 |
|
25946 | 130 |
// Count thread's native stack in "Thread" category |
131 |
if (flag == mtThread) { |
|
54292
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
132 |
if (ThreadStackTracker::track_as_vm()) { |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
133 |
const VirtualMemory* thread_stack_usage = |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
134 |
(const VirtualMemory*)_vm_snapshot->by_type(mtThreadStack); |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
135 |
reserved_amount += thread_stack_usage->reserved(); |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
136 |
committed_amount += thread_stack_usage->committed(); |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
137 |
} else { |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
138 |
const MallocMemory* thread_stack_usage = |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
139 |
(const MallocMemory*)_malloc_snapshot->by_type(mtThreadStack); |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
140 |
reserved_amount += thread_stack_usage->malloc_size(); |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
141 |
committed_amount += thread_stack_usage->malloc_size(); |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
142 |
} |
25946 | 143 |
} else if (flag == mtNMT) { |
144 |
// Count malloc headers in "NMT" category |
|
145 |
reserved_amount += _malloc_snapshot->malloc_overhead()->size(); |
|
146 |
committed_amount += _malloc_snapshot->malloc_overhead()->size(); |
|
13195 | 147 |
} |
148 |
||
25946 | 149 |
if (amount_in_current_scale(reserved_amount) > 0) { |
150 |
outputStream* out = output(); |
|
151 |
const char* scale = current_scale(); |
|
152 |
out->print("-%26s (", NMTUtil::flag_to_name(flag)); |
|
153 |
print_total(reserved_amount, committed_amount); |
|
154 |
out->print_cr(")"); |
|
13195 | 155 |
|
25946 | 156 |
if (flag == mtClass) { |
157 |
// report class count |
|
48884
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
158 |
out->print_cr("%27s (classes #" SIZE_FORMAT ")", |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
159 |
" ", (_instance_class_count + _array_class_count)); |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
160 |
out->print_cr("%27s ( instance classes #" SIZE_FORMAT ", array classes #" SIZE_FORMAT ")", |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
161 |
" ", _instance_class_count, _array_class_count); |
25946 | 162 |
} else if (flag == mtThread) { |
54292
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
163 |
if (ThreadStackTracker::track_as_vm()) { |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
164 |
const VirtualMemory* thread_stack_usage = |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
165 |
_vm_snapshot->by_type(mtThreadStack); |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
166 |
// report thread count |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
167 |
out->print_cr("%27s (thread #" SIZE_FORMAT ")", " ", ThreadStackTracker::thread_count()); |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
168 |
out->print("%27s (stack: ", " "); |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
169 |
print_total(thread_stack_usage->reserved(), thread_stack_usage->committed()); |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
170 |
} else { |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
171 |
MallocMemory* thread_stack_memory = _malloc_snapshot->by_type(mtThreadStack); |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
172 |
const char* scale = current_scale(); |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
173 |
// report thread count |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
174 |
assert(ThreadStackTracker::thread_count() == 0, "Not used"); |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
175 |
out->print_cr("%27s (thread #" SIZE_FORMAT ")", " ", thread_stack_memory->malloc_count()); |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
176 |
out->print("%27s (Stack: " SIZE_FORMAT "%s", " ", |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
177 |
amount_in_current_scale(thread_stack_memory->malloc_size()), scale); |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
178 |
} |
25946 | 179 |
out->print_cr(")"); |
180 |
} |
|
13195 | 181 |
|
25946 | 182 |
// report malloc'd memory |
183 |
if (amount_in_current_scale(malloc_memory->malloc_size()) > 0) { |
|
184 |
// We don't know how many arena chunks are in used, so don't report the count |
|
185 |
size_t count = (flag == mtChunk) ? 0 : malloc_memory->malloc_count(); |
|
186 |
print_malloc_line(malloc_memory->malloc_size(), count); |
|
187 |
} |
|
13195 | 188 |
|
25946 | 189 |
if (amount_in_current_scale(virtual_memory->reserved()) > 0) { |
190 |
print_virtual_memory_line(virtual_memory->reserved(), virtual_memory->committed()); |
|
191 |
} |
|
13195 | 192 |
|
25946 | 193 |
if (amount_in_current_scale(malloc_memory->arena_size()) > 0) { |
194 |
print_arena_line(malloc_memory->arena_size(), malloc_memory->arena_count()); |
|
195 |
} |
|
196 |
||
197 |
if (flag == mtNMT && |
|
198 |
amount_in_current_scale(_malloc_snapshot->malloc_overhead()->size()) > 0) { |
|
199 |
out->print_cr("%27s (tracking overhead=" SIZE_FORMAT "%s)", " ", |
|
200 |
amount_in_current_scale(_malloc_snapshot->malloc_overhead()->size()), scale); |
|
47553
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
201 |
} else if (flag == mtClass) { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
202 |
// Metadata information |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
203 |
report_metadata(Metaspace::NonClassType); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
204 |
if (Metaspace::using_class_space()) { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
205 |
report_metadata(Metaspace::ClassType); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
206 |
} |
25946 | 207 |
} |
208 |
out->print_cr(" "); |
|
13195 | 209 |
} |
210 |
} |
|
211 |
||
47553
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
212 |
void MemSummaryReporter::report_metadata(Metaspace::MetadataType type) const { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
213 |
assert(type == Metaspace::NonClassType || type == Metaspace::ClassType, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
214 |
"Invalid metadata type"); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
215 |
const char* name = (type == Metaspace::NonClassType) ? |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
216 |
"Metadata: " : "Class space:"; |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
217 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
218 |
outputStream* out = output(); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
219 |
const char* scale = current_scale(); |
49389
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49033
diff
changeset
|
220 |
size_t committed = MetaspaceUtils::committed_bytes(type); |
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49033
diff
changeset
|
221 |
size_t used = MetaspaceUtils::used_bytes(type); |
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49033
diff
changeset
|
222 |
size_t free = (MetaspaceUtils::capacity_bytes(type) - used) |
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49033
diff
changeset
|
223 |
+ MetaspaceUtils::free_chunks_total_bytes(type) |
49980 | 224 |
+ MetaspaceUtils::free_in_vs_bytes(type); |
47553
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
225 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
226 |
assert(committed >= used + free, "Sanity"); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
227 |
size_t waste = committed - (used + free); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
228 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
229 |
out->print_cr("%27s ( %s)", " ", name); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
230 |
out->print("%27s ( ", " "); |
49389
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49033
diff
changeset
|
231 |
print_total(MetaspaceUtils::reserved_bytes(type), committed); |
47553
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
232 |
out->print_cr(")"); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
233 |
out->print_cr("%27s ( used=" SIZE_FORMAT "%s)", " ", amount_in_current_scale(used), scale); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
234 |
out->print_cr("%27s ( free=" SIZE_FORMAT "%s)", " ", amount_in_current_scale(free), scale); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
235 |
out->print_cr("%27s ( waste=" SIZE_FORMAT "%s =%2.2f%%)", " ", amount_in_current_scale(waste), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
236 |
scale, ((float)waste * 100)/committed); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
237 |
} |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
238 |
|
25946 | 239 |
void MemDetailReporter::report_detail() { |
240 |
// Start detail report |
|
241 |
outputStream* out = output(); |
|
242 |
out->print_cr("Details:\n"); |
|
243 |
||
244 |
report_malloc_sites(); |
|
245 |
report_virtual_memory_allocation_sites(); |
|
246 |
} |
|
247 |
||
248 |
void MemDetailReporter::report_malloc_sites() { |
|
249 |
MallocSiteIterator malloc_itr = _baseline.malloc_sites(MemBaseline::by_size); |
|
250 |
if (malloc_itr.is_empty()) return; |
|
251 |
||
252 |
outputStream* out = output(); |
|
13195 | 253 |
|
25946 | 254 |
const MallocSite* malloc_site; |
255 |
while ((malloc_site = malloc_itr.next()) != NULL) { |
|
256 |
// Don't report if size is too small |
|
257 |
if (amount_in_current_scale(malloc_site->size()) == 0) |
|
258 |
continue; |
|
13195 | 259 |
|
25946 | 260 |
const NativeCallStack* stack = malloc_site->call_stack(); |
261 |
stack->print_on(out); |
|
262 |
out->print("%29s", " "); |
|
53685
df83034c9275
8218558: NMT stack traces in output should show mt component for virtual memory allocations
zgu
parents:
49980
diff
changeset
|
263 |
MEMFLAGS flag = malloc_site->flag(); |
46489
40abcea5a9d5
8139673: NMT stack traces in output should show mtcomponent
zgu
parents:
25946
diff
changeset
|
264 |
assert((flag >= 0 && flag < (int)mt_number_of_types) && flag != mtNone, |
40abcea5a9d5
8139673: NMT stack traces in output should show mtcomponent
zgu
parents:
25946
diff
changeset
|
265 |
"Must have a valid memory type"); |
40abcea5a9d5
8139673: NMT stack traces in output should show mtcomponent
zgu
parents:
25946
diff
changeset
|
266 |
print_malloc(malloc_site->size(), malloc_site->count(),flag); |
25946 | 267 |
out->print_cr("\n"); |
268 |
} |
|
269 |
} |
|
270 |
||
271 |
void MemDetailReporter::report_virtual_memory_allocation_sites() { |
|
272 |
VirtualMemorySiteIterator virtual_memory_itr = |
|
273 |
_baseline.virtual_memory_sites(MemBaseline::by_size); |
|
274 |
||
275 |
if (virtual_memory_itr.is_empty()) return; |
|
276 |
||
277 |
outputStream* out = output(); |
|
278 |
const VirtualMemoryAllocationSite* virtual_memory_site; |
|
13195 | 279 |
|
25946 | 280 |
while ((virtual_memory_site = virtual_memory_itr.next()) != NULL) { |
281 |
// Don't report if size is too small |
|
282 |
if (amount_in_current_scale(virtual_memory_site->reserved()) == 0) |
|
283 |
continue; |
|
284 |
||
285 |
const NativeCallStack* stack = virtual_memory_site->call_stack(); |
|
286 |
stack->print_on(out); |
|
287 |
out->print("%28s (", " "); |
|
288 |
print_total(virtual_memory_site->reserved(), virtual_memory_site->committed()); |
|
53685
df83034c9275
8218558: NMT stack traces in output should show mt component for virtual memory allocations
zgu
parents:
49980
diff
changeset
|
289 |
MEMFLAGS flag = virtual_memory_site->flag(); |
df83034c9275
8218558: NMT stack traces in output should show mt component for virtual memory allocations
zgu
parents:
49980
diff
changeset
|
290 |
if (flag != mtNone) { |
df83034c9275
8218558: NMT stack traces in output should show mt component for virtual memory allocations
zgu
parents:
49980
diff
changeset
|
291 |
out->print(" Type=%s", NMTUtil::flag_to_name(flag)); |
df83034c9275
8218558: NMT stack traces in output should show mt component for virtual memory allocations
zgu
parents:
49980
diff
changeset
|
292 |
} |
25946 | 293 |
out->print_cr(")\n"); |
294 |
} |
|
295 |
} |
|
296 |
||
297 |
||
298 |
void MemDetailReporter::report_virtual_memory_map() { |
|
299 |
// Virtual memory map always in base address order |
|
300 |
VirtualMemoryAllocationIterator itr = _baseline.virtual_memory_allocations(); |
|
301 |
const ReservedMemoryRegion* rgn; |
|
302 |
||
303 |
output()->print_cr("Virtual memory map:"); |
|
304 |
while ((rgn = itr.next()) != NULL) { |
|
305 |
report_virtual_memory_region(rgn); |
|
306 |
} |
|
307 |
} |
|
308 |
||
309 |
void MemDetailReporter::report_virtual_memory_region(const ReservedMemoryRegion* reserved_rgn) { |
|
310 |
assert(reserved_rgn != NULL, "NULL pointer"); |
|
311 |
||
312 |
// Don't report if size is too small |
|
313 |
if (amount_in_current_scale(reserved_rgn->size()) == 0) return; |
|
314 |
||
315 |
outputStream* out = output(); |
|
316 |
const char* scale = current_scale(); |
|
317 |
const NativeCallStack* stack = reserved_rgn->call_stack(); |
|
49033
3acc342c0738
8196405: [REDO] NMT: add_committed_regions doesn't merge succeeding regions
stefank
parents:
48884
diff
changeset
|
318 |
bool all_committed = reserved_rgn->size() == reserved_rgn->committed_size(); |
25946 | 319 |
const char* region_type = (all_committed ? "reserved and committed" : "reserved"); |
320 |
out->print_cr(" "); |
|
321 |
print_virtual_memory_region(region_type, reserved_rgn->base(), reserved_rgn->size()); |
|
322 |
out->print(" for %s", NMTUtil::flag_to_name(reserved_rgn->flag())); |
|
323 |
if (stack->is_empty()) { |
|
324 |
out->print_cr(" "); |
|
325 |
} else { |
|
326 |
out->print_cr(" from"); |
|
327 |
stack->print_on(out, 4); |
|
13195 | 328 |
} |
329 |
||
49033
3acc342c0738
8196405: [REDO] NMT: add_committed_regions doesn't merge succeeding regions
stefank
parents:
48884
diff
changeset
|
330 |
if (all_committed) { |
3acc342c0738
8196405: [REDO] NMT: add_committed_regions doesn't merge succeeding regions
stefank
parents:
48884
diff
changeset
|
331 |
CommittedRegionIterator itr = reserved_rgn->iterate_committed_regions(); |
3acc342c0738
8196405: [REDO] NMT: add_committed_regions doesn't merge succeeding regions
stefank
parents:
48884
diff
changeset
|
332 |
const CommittedMemoryRegion* committed_rgn = itr.next(); |
3acc342c0738
8196405: [REDO] NMT: add_committed_regions doesn't merge succeeding regions
stefank
parents:
48884
diff
changeset
|
333 |
if (committed_rgn->size() == reserved_rgn->size() && committed_rgn->call_stack()->equals(*stack)) { |
3acc342c0738
8196405: [REDO] NMT: add_committed_regions doesn't merge succeeding regions
stefank
parents:
48884
diff
changeset
|
334 |
// One region spanning the entire reserved region, with the same stack trace. |
3acc342c0738
8196405: [REDO] NMT: add_committed_regions doesn't merge succeeding regions
stefank
parents:
48884
diff
changeset
|
335 |
// Don't print this regions because the "reserved and committed" line above |
3acc342c0738
8196405: [REDO] NMT: add_committed_regions doesn't merge succeeding regions
stefank
parents:
48884
diff
changeset
|
336 |
// already indicates that the region is comitted. |
3acc342c0738
8196405: [REDO] NMT: add_committed_regions doesn't merge succeeding regions
stefank
parents:
48884
diff
changeset
|
337 |
assert(itr.next() == NULL, "Unexpectedly more than one regions"); |
3acc342c0738
8196405: [REDO] NMT: add_committed_regions doesn't merge succeeding regions
stefank
parents:
48884
diff
changeset
|
338 |
return; |
3acc342c0738
8196405: [REDO] NMT: add_committed_regions doesn't merge succeeding regions
stefank
parents:
48884
diff
changeset
|
339 |
} |
3acc342c0738
8196405: [REDO] NMT: add_committed_regions doesn't merge succeeding regions
stefank
parents:
48884
diff
changeset
|
340 |
} |
13195 | 341 |
|
25946 | 342 |
CommittedRegionIterator itr = reserved_rgn->iterate_committed_regions(); |
343 |
const CommittedMemoryRegion* committed_rgn; |
|
344 |
while ((committed_rgn = itr.next()) != NULL) { |
|
345 |
// Don't report if size is too small |
|
346 |
if (amount_in_current_scale(committed_rgn->size()) == 0) continue; |
|
347 |
stack = committed_rgn->call_stack(); |
|
348 |
out->print("\n\t"); |
|
349 |
print_virtual_memory_region("committed", committed_rgn->base(), committed_rgn->size()); |
|
350 |
if (stack->is_empty()) { |
|
351 |
out->print_cr(" "); |
|
352 |
} else { |
|
353 |
out->print_cr(" from"); |
|
354 |
stack->print_on(out, 12); |
|
13195 | 355 |
} |
356 |
} |
|
357 |
} |
|
358 |
||
25946 | 359 |
void MemSummaryDiffReporter::report_diff() { |
360 |
const char* scale = current_scale(); |
|
361 |
outputStream* out = output(); |
|
362 |
out->print_cr("\nNative Memory Tracking:\n"); |
|
13195 | 363 |
|
25946 | 364 |
// Overall diff |
365 |
out->print("Total: "); |
|
366 |
print_virtual_memory_diff(_current_baseline.total_reserved_memory(), |
|
367 |
_current_baseline.total_committed_memory(), _early_baseline.total_reserved_memory(), |
|
368 |
_early_baseline.total_committed_memory()); |
|
14120
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13195
diff
changeset
|
369 |
|
25946 | 370 |
out->print_cr("\n"); |
14120
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13195
diff
changeset
|
371 |
|
25946 | 372 |
// Summary diff by memory type |
373 |
for (int index = 0; index < mt_number_of_types; index ++) { |
|
374 |
MEMFLAGS flag = NMTUtil::index_to_flag(index); |
|
375 |
// thread stack is reported as part of thread category |
|
376 |
if (flag == mtThreadStack) continue; |
|
47553
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
377 |
diff_summary_of_type(flag, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
378 |
_early_baseline.malloc_memory(flag), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
379 |
_early_baseline.virtual_memory(flag), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
380 |
_early_baseline.metaspace_snapshot(), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
381 |
_current_baseline.malloc_memory(flag), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
382 |
_current_baseline.virtual_memory(flag), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
383 |
_current_baseline.metaspace_snapshot()); |
14120
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13195
diff
changeset
|
384 |
} |
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13195
diff
changeset
|
385 |
} |
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13195
diff
changeset
|
386 |
|
25946 | 387 |
void MemSummaryDiffReporter::print_malloc_diff(size_t current_amount, size_t current_count, |
46711
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
388 |
size_t early_amount, size_t early_count, MEMFLAGS flags) const { |
25946 | 389 |
const char* scale = current_scale(); |
390 |
outputStream* out = output(); |
|
54292
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
391 |
const char* alloc_type = (flags == mtThread) ? "" : "malloc="; |
13195 | 392 |
|
54292
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
393 |
out->print("%s" SIZE_FORMAT "%s", alloc_type, amount_in_current_scale(current_amount), scale); |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
394 |
// Report type only if it is valid and not under "thread" category |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
395 |
if (flags != mtNone && flags != mtThread) { |
46711
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
396 |
out->print(" type=%s", NMTUtil::flag_to_name(flags)); |
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
397 |
} |
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
398 |
|
25946 | 399 |
long amount_diff = diff_in_current_scale(current_amount, early_amount); |
400 |
if (amount_diff != 0) { |
|
401 |
out->print(" %+ld%s", amount_diff, scale); |
|
402 |
} |
|
403 |
if (current_count > 0) { |
|
404 |
out->print(" #" SIZE_FORMAT "", current_count); |
|
405 |
if (current_count != early_count) { |
|
406 |
out->print(" %+d", (int)(current_count - early_count)); |
|
13195 | 407 |
} |
408 |
} |
|
409 |
} |
|
410 |
||
25946 | 411 |
void MemSummaryDiffReporter::print_arena_diff(size_t current_amount, size_t current_count, |
412 |
size_t early_amount, size_t early_count) const { |
|
413 |
const char* scale = current_scale(); |
|
414 |
outputStream* out = output(); |
|
415 |
out->print("arena=" SIZE_FORMAT "%s", amount_in_current_scale(current_amount), scale); |
|
416 |
if (diff_in_current_scale(current_amount, early_amount) != 0) { |
|
417 |
out->print(" %+ld", diff_in_current_scale(current_amount, early_amount)); |
|
418 |
} |
|
419 |
||
420 |
out->print(" #" SIZE_FORMAT "", current_count); |
|
421 |
if (current_count != early_count) { |
|
422 |
out->print(" %+d", (int)(current_count - early_count)); |
|
423 |
} |
|
424 |
} |
|
13195 | 425 |
|
25946 | 426 |
void MemSummaryDiffReporter::print_virtual_memory_diff(size_t current_reserved, size_t current_committed, |
427 |
size_t early_reserved, size_t early_committed) const { |
|
428 |
const char* scale = current_scale(); |
|
429 |
outputStream* out = output(); |
|
430 |
out->print("reserved=" SIZE_FORMAT "%s", amount_in_current_scale(current_reserved), scale); |
|
431 |
long reserved_diff = diff_in_current_scale(current_reserved, early_reserved); |
|
432 |
if (reserved_diff != 0) { |
|
433 |
out->print(" %+ld%s", reserved_diff, scale); |
|
434 |
} |
|
435 |
||
436 |
out->print(", committed=" SIZE_FORMAT "%s", amount_in_current_scale(current_committed), scale); |
|
437 |
long committed_diff = diff_in_current_scale(current_committed, early_committed); |
|
438 |
if (committed_diff != 0) { |
|
439 |
out->print(" %+ld%s", committed_diff, scale); |
|
13195 | 440 |
} |
441 |
} |
|
442 |
||
25946 | 443 |
|
47553
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
444 |
void MemSummaryDiffReporter::diff_summary_of_type(MEMFLAGS flag, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
445 |
const MallocMemory* early_malloc, const VirtualMemory* early_vm, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
446 |
const MetaspaceSnapshot* early_ms, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
447 |
const MallocMemory* current_malloc, const VirtualMemory* current_vm, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
448 |
const MetaspaceSnapshot* current_ms) const { |
25946 | 449 |
|
450 |
outputStream* out = output(); |
|
451 |
const char* scale = current_scale(); |
|
452 |
||
453 |
// Total reserved and committed memory in current baseline |
|
454 |
size_t current_reserved_amount = reserved_total (current_malloc, current_vm); |
|
455 |
size_t current_committed_amount = committed_total(current_malloc, current_vm); |
|
456 |
||
457 |
// Total reserved and committed memory in early baseline |
|
458 |
size_t early_reserved_amount = reserved_total(early_malloc, early_vm); |
|
459 |
size_t early_committed_amount = committed_total(early_malloc, early_vm); |
|
13195 | 460 |
|
25946 | 461 |
// Adjust virtual memory total |
462 |
if (flag == mtThread) { |
|
463 |
const VirtualMemory* early_thread_stack_usage = |
|
464 |
_early_baseline.virtual_memory(mtThreadStack); |
|
465 |
const VirtualMemory* current_thread_stack_usage = |
|
466 |
_current_baseline.virtual_memory(mtThreadStack); |
|
467 |
||
468 |
early_reserved_amount += early_thread_stack_usage->reserved(); |
|
469 |
early_committed_amount += early_thread_stack_usage->committed(); |
|
470 |
||
471 |
current_reserved_amount += current_thread_stack_usage->reserved(); |
|
472 |
current_committed_amount += current_thread_stack_usage->committed(); |
|
473 |
} else if (flag == mtNMT) { |
|
474 |
early_reserved_amount += _early_baseline.malloc_tracking_overhead(); |
|
475 |
early_committed_amount += _early_baseline.malloc_tracking_overhead(); |
|
476 |
||
477 |
current_reserved_amount += _current_baseline.malloc_tracking_overhead(); |
|
478 |
current_committed_amount += _current_baseline.malloc_tracking_overhead(); |
|
479 |
} |
|
13195 | 480 |
|
25946 | 481 |
if (amount_in_current_scale(current_reserved_amount) > 0 || |
482 |
diff_in_current_scale(current_reserved_amount, early_reserved_amount) != 0) { |
|
483 |
||
484 |
// print summary line |
|
485 |
out->print("-%26s (", NMTUtil::flag_to_name(flag)); |
|
486 |
print_virtual_memory_diff(current_reserved_amount, current_committed_amount, |
|
487 |
early_reserved_amount, early_committed_amount); |
|
488 |
out->print_cr(")"); |
|
13195 | 489 |
|
25946 | 490 |
// detail lines |
491 |
if (flag == mtClass) { |
|
492 |
// report class count |
|
493 |
out->print("%27s (classes #" SIZE_FORMAT "", " ", _current_baseline.class_count()); |
|
494 |
int class_count_diff = (int)(_current_baseline.class_count() - |
|
495 |
_early_baseline.class_count()); |
|
496 |
if (_current_baseline.class_count() != _early_baseline.class_count()) { |
|
497 |
out->print(" %+d", (int)(_current_baseline.class_count() - _early_baseline.class_count())); |
|
498 |
} |
|
499 |
out->print_cr(")"); |
|
48884
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
500 |
|
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
501 |
out->print("%27s ( instance classes #" SIZE_FORMAT, " ", _current_baseline.instance_class_count()); |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
502 |
if (_current_baseline.instance_class_count() != _early_baseline.instance_class_count()) { |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
503 |
out->print(" %+d", (int)(_current_baseline.instance_class_count() - _early_baseline.instance_class_count())); |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
504 |
} |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
505 |
out->print(", array classes #" SIZE_FORMAT, _current_baseline.array_class_count()); |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
506 |
if (_current_baseline.array_class_count() != _early_baseline.array_class_count()) { |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
507 |
out->print(" %+d", (int)(_current_baseline.array_class_count() - _early_baseline.array_class_count())); |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
508 |
} |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
509 |
out->print_cr(")"); |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
510 |
|
25946 | 511 |
} else if (flag == mtThread) { |
512 |
// report thread count |
|
513 |
out->print("%27s (thread #" SIZE_FORMAT "", " ", _current_baseline.thread_count()); |
|
514 |
int thread_count_diff = (int)(_current_baseline.thread_count() - |
|
515 |
_early_baseline.thread_count()); |
|
516 |
if (thread_count_diff != 0) { |
|
517 |
out->print(" %+d", thread_count_diff); |
|
518 |
} |
|
519 |
out->print_cr(")"); |
|
13195 | 520 |
|
54292
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
521 |
out->print("%27s (stack: ", " "); |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
522 |
if (ThreadStackTracker::track_as_vm()) { |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
523 |
// report thread stack |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
524 |
const VirtualMemory* current_thread_stack = |
25946 | 525 |
_current_baseline.virtual_memory(mtThreadStack); |
54292
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
526 |
const VirtualMemory* early_thread_stack = |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
527 |
_early_baseline.virtual_memory(mtThreadStack); |
13195 | 528 |
|
54292
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
529 |
print_virtual_memory_diff(current_thread_stack->reserved(), current_thread_stack->committed(), |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
530 |
early_thread_stack->reserved(), early_thread_stack->committed()); |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
531 |
} else { |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
532 |
const MallocMemory* current_thread_stack = |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
533 |
_current_baseline.malloc_memory(mtThreadStack); |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
534 |
const MallocMemory* early_thread_stack = |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
535 |
_early_baseline.malloc_memory(mtThreadStack); |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
536 |
|
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
537 |
print_malloc_diff(current_thread_stack->malloc_size(), current_thread_stack->malloc_count(), |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
538 |
early_thread_stack->malloc_size(), early_thread_stack->malloc_count(), flag); |
c31faeacf00a
8204552: NMT: Separate thread stack tracking from virtual memory tracking
zgu
parents:
53709
diff
changeset
|
539 |
} |
25946 | 540 |
out->print_cr(")"); |
13195 | 541 |
} |
542 |
||
25946 | 543 |
// Report malloc'd memory |
544 |
size_t current_malloc_amount = current_malloc->malloc_size(); |
|
545 |
size_t early_malloc_amount = early_malloc->malloc_size(); |
|
546 |
if (amount_in_current_scale(current_malloc_amount) > 0 || |
|
547 |
diff_in_current_scale(current_malloc_amount, early_malloc_amount) != 0) { |
|
548 |
out->print("%28s(", " "); |
|
549 |
print_malloc_diff(current_malloc_amount, (flag == mtChunk) ? 0 : current_malloc->malloc_count(), |
|
46711
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
550 |
early_malloc_amount, early_malloc->malloc_count(), mtNone); |
25946 | 551 |
out->print_cr(")"); |
552 |
} |
|
13195 | 553 |
|
25946 | 554 |
// Report virtual memory |
555 |
if (amount_in_current_scale(current_vm->reserved()) > 0 || |
|
556 |
diff_in_current_scale(current_vm->reserved(), early_vm->reserved()) != 0) { |
|
557 |
out->print("%27s (mmap: ", " "); |
|
558 |
print_virtual_memory_diff(current_vm->reserved(), current_vm->committed(), |
|
559 |
early_vm->reserved(), early_vm->committed()); |
|
560 |
out->print_cr(")"); |
|
13195 | 561 |
} |
562 |
||
25946 | 563 |
// Report arena memory |
564 |
if (amount_in_current_scale(current_malloc->arena_size()) > 0 || |
|
565 |
diff_in_current_scale(current_malloc->arena_size(), early_malloc->arena_size()) != 0) { |
|
566 |
out->print("%28s(", " "); |
|
567 |
print_arena_diff(current_malloc->arena_size(), current_malloc->arena_count(), |
|
568 |
early_malloc->arena_size(), early_malloc->arena_count()); |
|
569 |
out->print_cr(")"); |
|
13195 | 570 |
} |
571 |
||
25946 | 572 |
// Report native memory tracking overhead |
573 |
if (flag == mtNMT) { |
|
574 |
size_t current_tracking_overhead = amount_in_current_scale(_current_baseline.malloc_tracking_overhead()); |
|
575 |
size_t early_tracking_overhead = amount_in_current_scale(_early_baseline.malloc_tracking_overhead()); |
|
13195 | 576 |
|
25946 | 577 |
out->print("%27s (tracking overhead=" SIZE_FORMAT "%s", " ", |
578 |
amount_in_current_scale(_current_baseline.malloc_tracking_overhead()), scale); |
|
13195 | 579 |
|
25946 | 580 |
long overhead_diff = diff_in_current_scale(_current_baseline.malloc_tracking_overhead(), |
581 |
_early_baseline.malloc_tracking_overhead()); |
|
582 |
if (overhead_diff != 0) { |
|
583 |
out->print(" %+ld%s", overhead_diff, scale); |
|
13195 | 584 |
} |
25946 | 585 |
out->print_cr(")"); |
47553
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
586 |
} else if (flag == mtClass) { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
587 |
assert(current_ms != NULL && early_ms != NULL, "Sanity"); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
588 |
print_metaspace_diff(current_ms, early_ms); |
13195 | 589 |
} |
25946 | 590 |
out->print_cr(" "); |
13195 | 591 |
} |
592 |
} |
|
593 |
||
47553
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
594 |
void MemSummaryDiffReporter::print_metaspace_diff(const MetaspaceSnapshot* current_ms, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
595 |
const MetaspaceSnapshot* early_ms) const { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
596 |
print_metaspace_diff(Metaspace::NonClassType, current_ms, early_ms); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
597 |
if (Metaspace::using_class_space()) { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
598 |
print_metaspace_diff(Metaspace::ClassType, current_ms, early_ms); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
599 |
} |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
600 |
} |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
601 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
602 |
void MemSummaryDiffReporter::print_metaspace_diff(Metaspace::MetadataType type, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
603 |
const MetaspaceSnapshot* current_ms, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
604 |
const MetaspaceSnapshot* early_ms) const { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
605 |
const char* name = (type == Metaspace::NonClassType) ? |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
606 |
"Metadata: " : "Class space:"; |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
607 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
608 |
outputStream* out = output(); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
609 |
const char* scale = current_scale(); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
610 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
611 |
out->print_cr("%27s ( %s)", " ", name); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
612 |
out->print("%27s ( ", " "); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
613 |
print_virtual_memory_diff(current_ms->reserved_in_bytes(type), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
614 |
current_ms->committed_in_bytes(type), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
615 |
early_ms->reserved_in_bytes(type), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
616 |
early_ms->committed_in_bytes(type)); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
617 |
out->print_cr(")"); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
618 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
619 |
long diff_used = diff_in_current_scale(current_ms->used_in_bytes(type), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
620 |
early_ms->used_in_bytes(type)); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
621 |
long diff_free = diff_in_current_scale(current_ms->free_in_bytes(type), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
622 |
early_ms->free_in_bytes(type)); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
623 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
624 |
size_t current_waste = current_ms->committed_in_bytes(type) |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
625 |
- (current_ms->used_in_bytes(type) + current_ms->free_in_bytes(type)); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
626 |
size_t early_waste = early_ms->committed_in_bytes(type) |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
627 |
- (early_ms->used_in_bytes(type) + early_ms->free_in_bytes(type)); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
628 |
long diff_waste = diff_in_current_scale(current_waste, early_waste); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
629 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
630 |
// Diff used |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
631 |
out->print("%27s ( used=" SIZE_FORMAT "%s", " ", |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
632 |
amount_in_current_scale(current_ms->used_in_bytes(type)), scale); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
633 |
if (diff_used != 0) { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
634 |
out->print(" %+ld%s", diff_used, scale); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
635 |
} |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
636 |
out->print_cr(")"); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
637 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
638 |
// Diff free |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
639 |
out->print("%27s ( free=" SIZE_FORMAT "%s", " ", |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
640 |
amount_in_current_scale(current_ms->free_in_bytes(type)), scale); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
641 |
if (diff_free != 0) { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
642 |
out->print(" %+ld%s", diff_free, scale); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
643 |
} |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
644 |
out->print_cr(")"); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
645 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
646 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
647 |
// Diff waste |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
648 |
out->print("%27s ( waste=" SIZE_FORMAT "%s =%2.2f%%", " ", |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
649 |
amount_in_current_scale(current_waste), scale, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
650 |
((float)current_waste * 100) / current_ms->committed_in_bytes(type)); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
651 |
if (diff_waste != 0) { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
652 |
out->print(" %+ld%s", diff_waste, scale); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
653 |
} |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
654 |
out->print_cr(")"); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
655 |
} |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
656 |
|
25946 | 657 |
void MemDetailDiffReporter::report_diff() { |
658 |
MemSummaryDiffReporter::report_diff(); |
|
659 |
diff_malloc_sites(); |
|
660 |
diff_virtual_memory_sites(); |
|
661 |
} |
|
662 |
||
663 |
void MemDetailDiffReporter::diff_malloc_sites() const { |
|
46711
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
664 |
MallocSiteIterator early_itr = _early_baseline.malloc_sites(MemBaseline::by_site_and_type); |
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
665 |
MallocSiteIterator current_itr = _current_baseline.malloc_sites(MemBaseline::by_site_and_type); |
25946 | 666 |
|
667 |
const MallocSite* early_site = early_itr.next(); |
|
668 |
const MallocSite* current_site = current_itr.next(); |
|
669 |
||
670 |
while (early_site != NULL || current_site != NULL) { |
|
671 |
if (early_site == NULL) { |
|
672 |
new_malloc_site(current_site); |
|
673 |
current_site = current_itr.next(); |
|
674 |
} else if (current_site == NULL) { |
|
675 |
old_malloc_site(early_site); |
|
676 |
early_site = early_itr.next(); |
|
13195 | 677 |
} else { |
25946 | 678 |
int compVal = current_site->call_stack()->compare(*early_site->call_stack()); |
679 |
if (compVal < 0) { |
|
680 |
new_malloc_site(current_site); |
|
681 |
current_site = current_itr.next(); |
|
682 |
} else if (compVal > 0) { |
|
683 |
old_malloc_site(early_site); |
|
684 |
early_site = early_itr.next(); |
|
13195 | 685 |
} else { |
25946 | 686 |
diff_malloc_site(early_site, current_site); |
687 |
early_site = early_itr.next(); |
|
688 |
current_site = current_itr.next(); |
|
13195 | 689 |
} |
690 |
} |
|
25946 | 691 |
} |
692 |
} |
|
13195 | 693 |
|
25946 | 694 |
void MemDetailDiffReporter::diff_virtual_memory_sites() const { |
695 |
VirtualMemorySiteIterator early_itr = _early_baseline.virtual_memory_sites(MemBaseline::by_site); |
|
696 |
VirtualMemorySiteIterator current_itr = _current_baseline.virtual_memory_sites(MemBaseline::by_site); |
|
697 |
||
698 |
const VirtualMemoryAllocationSite* early_site = early_itr.next(); |
|
699 |
const VirtualMemoryAllocationSite* current_site = current_itr.next(); |
|
700 |
||
701 |
while (early_site != NULL || current_site != NULL) { |
|
702 |
if (early_site == NULL) { |
|
703 |
new_virtual_memory_site(current_site); |
|
704 |
current_site = current_itr.next(); |
|
705 |
} else if (current_site == NULL) { |
|
706 |
old_virtual_memory_site(early_site); |
|
707 |
early_site = early_itr.next(); |
|
708 |
} else { |
|
709 |
int compVal = current_site->call_stack()->compare(*early_site->call_stack()); |
|
710 |
if (compVal < 0) { |
|
711 |
new_virtual_memory_site(current_site); |
|
712 |
current_site = current_itr.next(); |
|
713 |
} else if (compVal > 0) { |
|
714 |
old_virtual_memory_site(early_site); |
|
715 |
early_site = early_itr.next(); |
|
716 |
} else { |
|
717 |
diff_virtual_memory_site(early_site, current_site); |
|
718 |
early_site = early_itr.next(); |
|
719 |
current_site = current_itr.next(); |
|
720 |
} |
|
13195 | 721 |
} |
722 |
} |
|
723 |
} |
|
724 |
||
25946 | 725 |
|
726 |
void MemDetailDiffReporter::new_malloc_site(const MallocSite* malloc_site) const { |
|
727 |
diff_malloc_site(malloc_site->call_stack(), malloc_site->size(), malloc_site->count(), |
|
53685
df83034c9275
8218558: NMT stack traces in output should show mt component for virtual memory allocations
zgu
parents:
49980
diff
changeset
|
728 |
0, 0, malloc_site->flag()); |
25946 | 729 |
} |
730 |
||
731 |
void MemDetailDiffReporter::old_malloc_site(const MallocSite* malloc_site) const { |
|
732 |
diff_malloc_site(malloc_site->call_stack(), 0, 0, malloc_site->size(), |
|
53685
df83034c9275
8218558: NMT stack traces in output should show mt component for virtual memory allocations
zgu
parents:
49980
diff
changeset
|
733 |
malloc_site->count(), malloc_site->flag()); |
25946 | 734 |
} |
735 |
||
736 |
void MemDetailDiffReporter::diff_malloc_site(const MallocSite* early, |
|
737 |
const MallocSite* current) const { |
|
53709
2b64ebacce93
8200109: NMT: diff_malloc_site assert(early->flags() == current->flags(), "Must be the same memory type")
zgu
parents:
53685
diff
changeset
|
738 |
if (early->flag() != current->flag()) { |
2b64ebacce93
8200109: NMT: diff_malloc_site assert(early->flags() == current->flags(), "Must be the same memory type")
zgu
parents:
53685
diff
changeset
|
739 |
// If malloc site type changed, treat it as deallocation of old type and |
2b64ebacce93
8200109: NMT: diff_malloc_site assert(early->flags() == current->flags(), "Must be the same memory type")
zgu
parents:
53685
diff
changeset
|
740 |
// allocation of new type. |
2b64ebacce93
8200109: NMT: diff_malloc_site assert(early->flags() == current->flags(), "Must be the same memory type")
zgu
parents:
53685
diff
changeset
|
741 |
old_malloc_site(early); |
2b64ebacce93
8200109: NMT: diff_malloc_site assert(early->flags() == current->flags(), "Must be the same memory type")
zgu
parents:
53685
diff
changeset
|
742 |
new_malloc_site(current); |
2b64ebacce93
8200109: NMT: diff_malloc_site assert(early->flags() == current->flags(), "Must be the same memory type")
zgu
parents:
53685
diff
changeset
|
743 |
} else { |
2b64ebacce93
8200109: NMT: diff_malloc_site assert(early->flags() == current->flags(), "Must be the same memory type")
zgu
parents:
53685
diff
changeset
|
744 |
diff_malloc_site(current->call_stack(), current->size(), current->count(), |
2b64ebacce93
8200109: NMT: diff_malloc_site assert(early->flags() == current->flags(), "Must be the same memory type")
zgu
parents:
53685
diff
changeset
|
745 |
early->size(), early->count(), early->flag()); |
2b64ebacce93
8200109: NMT: diff_malloc_site assert(early->flags() == current->flags(), "Must be the same memory type")
zgu
parents:
53685
diff
changeset
|
746 |
} |
25946 | 747 |
} |
748 |
||
749 |
void MemDetailDiffReporter::diff_malloc_site(const NativeCallStack* stack, size_t current_size, |
|
46711
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
750 |
size_t current_count, size_t early_size, size_t early_count, MEMFLAGS flags) const { |
25946 | 751 |
outputStream* out = output(); |
752 |
||
753 |
assert(stack != NULL, "NULL stack"); |
|
754 |
||
755 |
if (diff_in_current_scale(current_size, early_size) == 0) { |
|
756 |
return; |
|
757 |
} |
|
758 |
||
759 |
stack->print_on(out); |
|
760 |
out->print("%28s (", " "); |
|
761 |
print_malloc_diff(current_size, current_count, |
|
46711
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
762 |
early_size, early_count, flags); |
13195 | 763 |
|
25946 | 764 |
out->print_cr(")\n"); |
765 |
} |
|
766 |
||
767 |
||
768 |
void MemDetailDiffReporter::new_virtual_memory_site(const VirtualMemoryAllocationSite* site) const { |
|
53685
df83034c9275
8218558: NMT stack traces in output should show mt component for virtual memory allocations
zgu
parents:
49980
diff
changeset
|
769 |
diff_virtual_memory_site(site->call_stack(), site->reserved(), site->committed(), 0, 0, site->flag()); |
25946 | 770 |
} |
771 |
||
772 |
void MemDetailDiffReporter::old_virtual_memory_site(const VirtualMemoryAllocationSite* site) const { |
|
53685
df83034c9275
8218558: NMT stack traces in output should show mt component for virtual memory allocations
zgu
parents:
49980
diff
changeset
|
773 |
diff_virtual_memory_site(site->call_stack(), 0, 0, site->reserved(), site->committed(), site->flag()); |
25946 | 774 |
} |
775 |
||
776 |
void MemDetailDiffReporter::diff_virtual_memory_site(const VirtualMemoryAllocationSite* early, |
|
777 |
const VirtualMemoryAllocationSite* current) const { |
|
53685
df83034c9275
8218558: NMT stack traces in output should show mt component for virtual memory allocations
zgu
parents:
49980
diff
changeset
|
778 |
assert(early->flag() == current->flag(), "Should be the same"); |
25946 | 779 |
diff_virtual_memory_site(current->call_stack(), current->reserved(), current->committed(), |
53685
df83034c9275
8218558: NMT stack traces in output should show mt component for virtual memory allocations
zgu
parents:
49980
diff
changeset
|
780 |
early->reserved(), early->committed(), current->flag()); |
25946 | 781 |
} |
782 |
||
783 |
void MemDetailDiffReporter::diff_virtual_memory_site(const NativeCallStack* stack, size_t current_reserved, |
|
53685
df83034c9275
8218558: NMT stack traces in output should show mt component for virtual memory allocations
zgu
parents:
49980
diff
changeset
|
784 |
size_t current_committed, size_t early_reserved, size_t early_committed, MEMFLAGS flag) const { |
25946 | 785 |
outputStream* out = output(); |
786 |
||
787 |
// no change |
|
788 |
if (diff_in_current_scale(current_reserved, early_reserved) == 0 && |
|
789 |
diff_in_current_scale(current_committed, early_committed) == 0) { |
|
790 |
return; |
|
13195 | 791 |
} |
25946 | 792 |
|
793 |
stack->print_on(out); |
|
794 |
out->print("%28s (mmap: ", " "); |
|
795 |
print_virtual_memory_diff(current_reserved, current_committed, |
|
796 |
early_reserved, early_committed); |
|
797 |
||
53685
df83034c9275
8218558: NMT stack traces in output should show mt component for virtual memory allocations
zgu
parents:
49980
diff
changeset
|
798 |
if (flag != mtNone) { |
df83034c9275
8218558: NMT stack traces in output should show mt component for virtual memory allocations
zgu
parents:
49980
diff
changeset
|
799 |
out->print(" Type=%s", NMTUtil::flag_to_name(flag)); |
df83034c9275
8218558: NMT stack traces in output should show mt component for virtual memory allocations
zgu
parents:
49980
diff
changeset
|
800 |
} |
df83034c9275
8218558: NMT stack traces in output should show mt component for virtual memory allocations
zgu
parents:
49980
diff
changeset
|
801 |
|
25946 | 802 |
out->print_cr(")\n"); |
803 |
} |