13195
|
1 |
/*
|
|
2 |
* Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
|
|
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"
|
|
25 |
#include "classfile/systemDictionary.hpp"
|
|
26 |
#include "runtime/os.hpp"
|
|
27 |
#include "services/memReporter.hpp"
|
|
28 |
#include "services/memPtrArray.hpp"
|
|
29 |
#include "services/memTracker.hpp"
|
|
30 |
|
|
31 |
const char* BaselineOutputer::memory_unit(size_t scale) {
|
|
32 |
switch(scale) {
|
|
33 |
case K: return "KB";
|
|
34 |
case M: return "MB";
|
|
35 |
case G: return "GB";
|
|
36 |
}
|
|
37 |
ShouldNotReachHere();
|
|
38 |
return NULL;
|
|
39 |
}
|
|
40 |
|
|
41 |
|
|
42 |
void BaselineReporter::report_baseline(const MemBaseline& baseline, bool summary_only) {
|
|
43 |
assert(MemTracker::is_on(), "Native memory tracking is off");
|
|
44 |
_outputer.start(scale());
|
|
45 |
_outputer.total_usage(
|
|
46 |
amount_in_current_scale(baseline.total_malloc_amount() + baseline.total_reserved_amount()),
|
|
47 |
amount_in_current_scale(baseline.total_malloc_amount() + baseline.total_committed_amount()));
|
|
48 |
|
|
49 |
_outputer.num_of_classes(baseline.number_of_classes());
|
|
50 |
_outputer.num_of_threads(baseline.number_of_threads());
|
|
51 |
|
|
52 |
report_summaries(baseline);
|
|
53 |
if (!summary_only && MemTracker::track_callsite()) {
|
|
54 |
report_callsites(baseline);
|
|
55 |
}
|
|
56 |
_outputer.done();
|
|
57 |
}
|
|
58 |
|
|
59 |
void BaselineReporter::report_summaries(const MemBaseline& baseline) {
|
|
60 |
_outputer.start_category_summary();
|
|
61 |
MEMFLAGS type;
|
|
62 |
|
|
63 |
for (int index = 0; index < NUMBER_OF_MEMORY_TYPE; index ++) {
|
|
64 |
type = MemBaseline::MemType2NameMap[index]._flag;
|
|
65 |
_outputer.category_summary(type,
|
|
66 |
amount_in_current_scale(baseline.reserved_amount(type)),
|
|
67 |
amount_in_current_scale(baseline.committed_amount(type)),
|
|
68 |
amount_in_current_scale(baseline.malloc_amount(type)),
|
|
69 |
baseline.malloc_count(type),
|
|
70 |
amount_in_current_scale(baseline.arena_amount(type)),
|
|
71 |
baseline.arena_count(type));
|
|
72 |
}
|
|
73 |
|
|
74 |
_outputer.done_category_summary();
|
|
75 |
}
|
|
76 |
|
|
77 |
void BaselineReporter::report_callsites(const MemBaseline& baseline) {
|
|
78 |
_outputer.start_callsite();
|
|
79 |
MemBaseline* pBL = const_cast<MemBaseline*>(&baseline);
|
|
80 |
|
|
81 |
pBL->_malloc_cs->sort((FN_SORT)MemBaseline::bl_malloc_sort_by_size);
|
|
82 |
pBL->_vm_cs->sort((FN_SORT)MemBaseline::bl_vm_sort_by_size);
|
|
83 |
|
|
84 |
// walk malloc callsites
|
|
85 |
MemPointerArrayIteratorImpl malloc_itr(pBL->_malloc_cs);
|
|
86 |
MallocCallsitePointer* malloc_callsite =
|
|
87 |
(MallocCallsitePointer*)malloc_itr.current();
|
|
88 |
while (malloc_callsite != NULL) {
|
|
89 |
_outputer.malloc_callsite(malloc_callsite->addr(),
|
|
90 |
amount_in_current_scale(malloc_callsite->amount()), malloc_callsite->count());
|
|
91 |
malloc_callsite = (MallocCallsitePointer*)malloc_itr.next();
|
|
92 |
}
|
|
93 |
|
|
94 |
// walk virtual memory callsite
|
|
95 |
MemPointerArrayIteratorImpl vm_itr(pBL->_vm_cs);
|
|
96 |
VMCallsitePointer* vm_callsite = (VMCallsitePointer*)vm_itr.current();
|
|
97 |
while (vm_callsite != NULL) {
|
|
98 |
_outputer.virtual_memory_callsite(vm_callsite->addr(),
|
|
99 |
amount_in_current_scale(vm_callsite->reserved_amount()),
|
|
100 |
amount_in_current_scale(vm_callsite->committed_amount()));
|
|
101 |
vm_callsite = (VMCallsitePointer*)vm_itr.next();
|
|
102 |
}
|
|
103 |
pBL->_malloc_cs->sort((FN_SORT)MemBaseline::bl_malloc_sort_by_pc);
|
|
104 |
pBL->_vm_cs->sort((FN_SORT)MemBaseline::bl_vm_sort_by_pc);
|
|
105 |
_outputer.done_callsite();
|
|
106 |
}
|
|
107 |
|
|
108 |
void BaselineReporter::diff_baselines(const MemBaseline& cur, const MemBaseline& prev,
|
|
109 |
bool summary_only) {
|
|
110 |
assert(MemTracker::is_on(), "Native memory tracking is off");
|
|
111 |
_outputer.start(scale());
|
|
112 |
size_t total_reserved = cur.total_malloc_amount() + cur.total_reserved_amount();
|
|
113 |
size_t total_committed = cur.total_malloc_amount() + cur.total_committed_amount();
|
|
114 |
|
|
115 |
_outputer.diff_total_usage(
|
|
116 |
amount_in_current_scale(total_reserved), amount_in_current_scale(total_committed),
|
|
117 |
diff_in_current_scale(total_reserved, (prev.total_malloc_amount() + prev.total_reserved_amount())),
|
|
118 |
diff_in_current_scale(total_committed, (prev.total_committed_amount() + prev.total_malloc_amount())));
|
|
119 |
|
|
120 |
_outputer.diff_num_of_classes(cur.number_of_classes(),
|
|
121 |
diff(cur.number_of_classes(), prev.number_of_classes()));
|
|
122 |
_outputer.diff_num_of_threads(cur.number_of_threads(),
|
|
123 |
diff(cur.number_of_threads(), prev.number_of_threads()));
|
|
124 |
|
|
125 |
diff_summaries(cur, prev);
|
|
126 |
if (!summary_only && MemTracker::track_callsite()) {
|
|
127 |
diff_callsites(cur, prev);
|
|
128 |
}
|
|
129 |
_outputer.done();
|
|
130 |
}
|
|
131 |
|
|
132 |
void BaselineReporter::diff_summaries(const MemBaseline& cur, const MemBaseline& prev) {
|
|
133 |
_outputer.start_category_summary();
|
|
134 |
MEMFLAGS type;
|
|
135 |
|
|
136 |
for (int index = 0; index < NUMBER_OF_MEMORY_TYPE; index ++) {
|
|
137 |
type = MemBaseline::MemType2NameMap[index]._flag;
|
|
138 |
_outputer.diff_category_summary(type,
|
|
139 |
amount_in_current_scale(cur.reserved_amount(type)),
|
|
140 |
amount_in_current_scale(cur.committed_amount(type)),
|
|
141 |
amount_in_current_scale(cur.malloc_amount(type)),
|
|
142 |
cur.malloc_count(type),
|
|
143 |
amount_in_current_scale(cur.arena_amount(type)),
|
|
144 |
cur.arena_count(type),
|
|
145 |
diff_in_current_scale(cur.reserved_amount(type), prev.reserved_amount(type)),
|
|
146 |
diff_in_current_scale(cur.committed_amount(type), prev.committed_amount(type)),
|
|
147 |
diff_in_current_scale(cur.malloc_amount(type), prev.malloc_amount(type)),
|
|
148 |
diff(cur.malloc_count(type), prev.malloc_count(type)),
|
|
149 |
diff_in_current_scale(cur.arena_amount(type), prev.arena_amount(type)),
|
|
150 |
diff(cur.arena_count(type), prev.arena_count(type)));
|
|
151 |
}
|
|
152 |
|
|
153 |
_outputer.done_category_summary();
|
|
154 |
}
|
|
155 |
|
|
156 |
void BaselineReporter::diff_callsites(const MemBaseline& cur, const MemBaseline& prev) {
|
|
157 |
_outputer.start_callsite();
|
|
158 |
MemBaseline* pBL_cur = const_cast<MemBaseline*>(&cur);
|
|
159 |
MemBaseline* pBL_prev = const_cast<MemBaseline*>(&prev);
|
|
160 |
|
|
161 |
// walk malloc callsites
|
|
162 |
MemPointerArrayIteratorImpl cur_malloc_itr(pBL_cur->_malloc_cs);
|
|
163 |
MemPointerArrayIteratorImpl prev_malloc_itr(pBL_prev->_malloc_cs);
|
|
164 |
|
|
165 |
MallocCallsitePointer* cur_malloc_callsite =
|
|
166 |
(MallocCallsitePointer*)cur_malloc_itr.current();
|
|
167 |
MallocCallsitePointer* prev_malloc_callsite =
|
|
168 |
(MallocCallsitePointer*)prev_malloc_itr.current();
|
|
169 |
|
|
170 |
while (cur_malloc_callsite != NULL || prev_malloc_callsite != NULL) {
|
|
171 |
if (prev_malloc_callsite == NULL ||
|
|
172 |
cur_malloc_callsite->addr() < prev_malloc_callsite->addr()) {
|
|
173 |
_outputer.diff_malloc_callsite(cur_malloc_callsite->addr(),
|
|
174 |
amount_in_current_scale(cur_malloc_callsite->amount()),
|
|
175 |
cur_malloc_callsite->count(),
|
|
176 |
diff_in_current_scale(cur_malloc_callsite->amount(), 0),
|
|
177 |
diff(cur_malloc_callsite->count(), 0));
|
|
178 |
cur_malloc_callsite = (MallocCallsitePointer*)cur_malloc_itr.next();
|
|
179 |
} else if (prev_malloc_callsite == NULL ||
|
|
180 |
cur_malloc_callsite->addr() > prev_malloc_callsite->addr()) {
|
|
181 |
_outputer.diff_malloc_callsite(cur_malloc_callsite->addr(),
|
|
182 |
amount_in_current_scale(prev_malloc_callsite->amount()),
|
|
183 |
prev_malloc_callsite->count(),
|
|
184 |
diff_in_current_scale(0, prev_malloc_callsite->amount()),
|
|
185 |
diff(0, prev_malloc_callsite->count()));
|
|
186 |
prev_malloc_callsite = (MallocCallsitePointer*)prev_malloc_itr.next();
|
|
187 |
} else { // the same callsite
|
|
188 |
_outputer.diff_malloc_callsite(cur_malloc_callsite->addr(),
|
|
189 |
amount_in_current_scale(cur_malloc_callsite->amount()),
|
|
190 |
cur_malloc_callsite->count(),
|
|
191 |
diff_in_current_scale(cur_malloc_callsite->amount(), prev_malloc_callsite->amount()),
|
|
192 |
diff(cur_malloc_callsite->count(), prev_malloc_callsite->count()));
|
|
193 |
cur_malloc_callsite = (MallocCallsitePointer*)cur_malloc_itr.next();
|
|
194 |
prev_malloc_callsite = (MallocCallsitePointer*)prev_malloc_itr.next();
|
|
195 |
}
|
|
196 |
}
|
|
197 |
|
|
198 |
// walk virtual memory callsite
|
|
199 |
MemPointerArrayIteratorImpl cur_vm_itr(pBL_cur->_vm_cs);
|
|
200 |
MemPointerArrayIteratorImpl prev_vm_itr(pBL_prev->_vm_cs);
|
|
201 |
VMCallsitePointer* cur_vm_callsite = (VMCallsitePointer*)cur_vm_itr.current();
|
|
202 |
VMCallsitePointer* prev_vm_callsite = (VMCallsitePointer*)prev_vm_itr.current();
|
|
203 |
while (cur_vm_callsite != NULL || prev_vm_callsite != NULL) {
|
|
204 |
if (prev_vm_callsite == NULL || cur_vm_callsite->addr() < prev_vm_callsite->addr()) {
|
|
205 |
_outputer.diff_virtual_memory_callsite(cur_vm_callsite->addr(),
|
|
206 |
amount_in_current_scale(cur_vm_callsite->reserved_amount()),
|
|
207 |
amount_in_current_scale(cur_vm_callsite->committed_amount()),
|
|
208 |
diff_in_current_scale(cur_vm_callsite->reserved_amount(), 0),
|
|
209 |
diff_in_current_scale(cur_vm_callsite->committed_amount(), 0));
|
|
210 |
cur_vm_callsite = (VMCallsitePointer*)cur_vm_itr.next();
|
|
211 |
} else if (cur_vm_callsite == NULL || cur_vm_callsite->addr() > prev_vm_callsite->addr()) {
|
|
212 |
_outputer.diff_virtual_memory_callsite(prev_vm_callsite->addr(),
|
|
213 |
amount_in_current_scale(prev_vm_callsite->reserved_amount()),
|
|
214 |
amount_in_current_scale(prev_vm_callsite->committed_amount()),
|
|
215 |
diff_in_current_scale(0, prev_vm_callsite->reserved_amount()),
|
|
216 |
diff_in_current_scale(0, prev_vm_callsite->committed_amount()));
|
|
217 |
prev_vm_callsite = (VMCallsitePointer*)prev_vm_itr.next();
|
|
218 |
} else { // the same callsite
|
|
219 |
_outputer.diff_virtual_memory_callsite(cur_vm_callsite->addr(),
|
|
220 |
amount_in_current_scale(cur_vm_callsite->reserved_amount()),
|
|
221 |
amount_in_current_scale(cur_vm_callsite->committed_amount()),
|
|
222 |
diff_in_current_scale(cur_vm_callsite->reserved_amount(), prev_vm_callsite->reserved_amount()),
|
|
223 |
diff_in_current_scale(cur_vm_callsite->committed_amount(), prev_vm_callsite->committed_amount()));
|
|
224 |
cur_vm_callsite = (VMCallsitePointer*)cur_vm_itr.next();
|
|
225 |
prev_vm_callsite = (VMCallsitePointer*)prev_vm_itr.next();
|
|
226 |
}
|
|
227 |
}
|
|
228 |
|
|
229 |
_outputer.done_callsite();
|
|
230 |
}
|
|
231 |
|
|
232 |
size_t BaselineReporter::amount_in_current_scale(size_t amt) const {
|
|
233 |
return (size_t)(((float)amt/(float)_scale) + 0.5);
|
|
234 |
}
|
|
235 |
|
|
236 |
int BaselineReporter::diff_in_current_scale(size_t value1, size_t value2) const {
|
|
237 |
return (int)(((float)value1 - (float)value2)/((float)_scale) + 0.5);
|
|
238 |
}
|
|
239 |
|
|
240 |
int BaselineReporter::diff(size_t value1, size_t value2) const {
|
|
241 |
return ((int)value1 - (int)value2);
|
|
242 |
}
|
|
243 |
|
|
244 |
void BaselineTTYOutputer::start(size_t scale, bool report_diff) {
|
|
245 |
_scale = scale;
|
|
246 |
_output->print_cr(" ");
|
|
247 |
_output->print_cr("Native Memory Tracking:");
|
|
248 |
_output->print_cr(" ");
|
|
249 |
}
|
|
250 |
|
|
251 |
void BaselineTTYOutputer::done() {
|
|
252 |
|
|
253 |
}
|
|
254 |
|
|
255 |
void BaselineTTYOutputer::total_usage(size_t total_reserved, size_t total_committed) {
|
|
256 |
const char* unit = memory_unit(_scale);
|
|
257 |
_output->print_cr("Total: reserved=%d%s, committed=%d%s",
|
|
258 |
total_reserved, unit, total_committed, unit);
|
|
259 |
}
|
|
260 |
|
|
261 |
void BaselineTTYOutputer::start_category_summary() {
|
|
262 |
_output->print_cr(" ");
|
|
263 |
}
|
|
264 |
|
|
265 |
/**
|
|
266 |
* report a summary of memory type
|
|
267 |
*/
|
|
268 |
void BaselineTTYOutputer::category_summary(MEMFLAGS type,
|
|
269 |
size_t reserved_amt, size_t committed_amt, size_t malloc_amt,
|
|
270 |
size_t malloc_count, size_t arena_amt, size_t arena_count) {
|
|
271 |
|
|
272 |
// we report mtThreadStack under mtThread category
|
|
273 |
if (type == mtThreadStack) {
|
|
274 |
assert(malloc_amt == 0 && malloc_count == 0 && arena_amt == 0,
|
|
275 |
"Just check");
|
|
276 |
_thread_stack_reserved = reserved_amt;
|
|
277 |
_thread_stack_committed = committed_amt;
|
|
278 |
} else {
|
|
279 |
const char* unit = memory_unit(_scale);
|
|
280 |
size_t total_reserved = (reserved_amt + malloc_amt + arena_amt);
|
|
281 |
size_t total_committed = (committed_amt + malloc_amt + arena_amt);
|
|
282 |
if (type == mtThread) {
|
|
283 |
total_reserved += _thread_stack_reserved;
|
|
284 |
total_committed += _thread_stack_committed;
|
|
285 |
}
|
|
286 |
|
|
287 |
if (total_reserved > 0) {
|
|
288 |
_output->print_cr("-%26s (reserved=%d%s, committed=%d%s)",
|
|
289 |
MemBaseline::type2name(type), total_reserved, unit,
|
|
290 |
total_committed, unit);
|
|
291 |
|
|
292 |
if (type == mtClass) {
|
|
293 |
_output->print_cr("%27s (classes #%d)", " ", _num_of_classes);
|
|
294 |
} else if (type == mtThread) {
|
|
295 |
_output->print_cr("%27s (thread #%d)", " ", _num_of_threads);
|
|
296 |
_output->print_cr("%27s (stack: reserved=%d%s, committed=%d%s)", " ",
|
|
297 |
_thread_stack_reserved, unit, _thread_stack_committed, unit);
|
|
298 |
}
|
|
299 |
|
|
300 |
if (malloc_amt > 0) {
|
|
301 |
if (type != mtChunk) {
|
|
302 |
_output->print_cr("%27s (malloc=%d%s, #%d)", " ", malloc_amt, unit,
|
|
303 |
malloc_count);
|
|
304 |
} else {
|
|
305 |
_output->print_cr("%27s (malloc=%d%s)", " ", malloc_amt, unit);
|
|
306 |
}
|
|
307 |
}
|
|
308 |
|
|
309 |
if (reserved_amt > 0) {
|
|
310 |
_output->print_cr("%27s (mmap: reserved=%d%s, committed=%d%s)",
|
|
311 |
" ", reserved_amt, unit, committed_amt, unit);
|
|
312 |
}
|
|
313 |
|
|
314 |
if (arena_amt > 0) {
|
|
315 |
_output->print_cr("%27s (arena=%d%s, #%d)", " ", arena_amt, unit, arena_count);
|
|
316 |
}
|
|
317 |
|
|
318 |
_output->print_cr(" ");
|
|
319 |
}
|
|
320 |
}
|
|
321 |
}
|
|
322 |
|
|
323 |
void BaselineTTYOutputer::done_category_summary() {
|
|
324 |
_output->print_cr(" ");
|
|
325 |
}
|
|
326 |
|
|
327 |
void BaselineTTYOutputer::start_callsite() {
|
|
328 |
_output->print_cr("Details:");
|
|
329 |
_output->print_cr(" ");
|
|
330 |
}
|
|
331 |
|
|
332 |
void BaselineTTYOutputer::done_callsite() {
|
|
333 |
_output->print_cr(" ");
|
|
334 |
}
|
|
335 |
|
|
336 |
void BaselineTTYOutputer::malloc_callsite(address pc, size_t malloc_amt,
|
|
337 |
size_t malloc_count) {
|
|
338 |
if (malloc_amt > 0) {
|
|
339 |
const char* unit = memory_unit(_scale);
|
|
340 |
char buf[64];
|
|
341 |
int offset;
|
|
342 |
if (pc == 0) {
|
|
343 |
_output->print("[BOOTSTRAP]%18s", " ");
|
|
344 |
} else if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) {
|
|
345 |
_output->print_cr("[" PTR_FORMAT "] %s+0x%x", pc, buf, offset);
|
|
346 |
_output->print("%28s", " ");
|
|
347 |
} else {
|
|
348 |
_output->print("[" PTR_FORMAT "]%18s", pc, " ");
|
|
349 |
}
|
|
350 |
|
|
351 |
_output->print_cr("(malloc=%d%s #%d)", malloc_amt, unit, malloc_count);
|
|
352 |
_output->print_cr(" ");
|
|
353 |
}
|
|
354 |
}
|
|
355 |
|
|
356 |
void BaselineTTYOutputer::virtual_memory_callsite(address pc, size_t reserved_amt,
|
|
357 |
size_t committed_amt) {
|
|
358 |
if (reserved_amt > 0) {
|
|
359 |
const char* unit = memory_unit(_scale);
|
|
360 |
char buf[64];
|
|
361 |
int offset;
|
|
362 |
if (pc == 0) {
|
|
363 |
_output->print("[BOOTSTRAP]%18s", " ");
|
|
364 |
} else if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) {
|
|
365 |
_output->print_cr("[" PTR_FORMAT "] %s+0x%x", pc, buf, offset);
|
|
366 |
_output->print("%28s", " ");
|
|
367 |
} else {
|
|
368 |
_output->print("[" PTR_FORMAT "]%18s", " ");
|
|
369 |
}
|
|
370 |
|
|
371 |
_output->print_cr("(mmap: reserved=%d%s, committed=%d%s)",
|
|
372 |
reserved_amt, unit, committed_amt, unit);
|
|
373 |
_output->print_cr(" ");
|
|
374 |
}
|
|
375 |
}
|
|
376 |
|
|
377 |
void BaselineTTYOutputer::diff_total_usage(size_t total_reserved,
|
|
378 |
size_t total_committed, int reserved_diff, int committed_diff) {
|
|
379 |
const char* unit = memory_unit(_scale);
|
|
380 |
_output->print_cr("Total: reserved=%d%s %+d%s, committed=%d%s %+d%s",
|
|
381 |
total_reserved, unit, reserved_diff, unit, total_committed, unit,
|
|
382 |
committed_diff, unit);
|
|
383 |
}
|
|
384 |
|
|
385 |
void BaselineTTYOutputer::diff_category_summary(MEMFLAGS type,
|
|
386 |
size_t cur_reserved_amt, size_t cur_committed_amt,
|
|
387 |
size_t cur_malloc_amt, size_t cur_malloc_count,
|
|
388 |
size_t cur_arena_amt, size_t cur_arena_count,
|
|
389 |
int reserved_diff, int committed_diff, int malloc_diff,
|
|
390 |
int malloc_count_diff, int arena_diff, int arena_count_diff) {
|
|
391 |
|
|
392 |
if (type == mtThreadStack) {
|
|
393 |
assert(cur_malloc_amt == 0 && cur_malloc_count == 0 &&
|
|
394 |
cur_arena_amt == 0, "Just check");
|
|
395 |
_thread_stack_reserved = cur_reserved_amt;
|
|
396 |
_thread_stack_committed = cur_committed_amt;
|
|
397 |
_thread_stack_reserved_diff = reserved_diff;
|
|
398 |
_thread_stack_committed_diff = committed_diff;
|
|
399 |
} else {
|
|
400 |
const char* unit = memory_unit(_scale);
|
|
401 |
size_t total_reserved = (cur_reserved_amt + cur_malloc_amt + cur_arena_amt);
|
|
402 |
// nothing to report in this category
|
|
403 |
if (total_reserved == 0) {
|
|
404 |
return;
|
|
405 |
}
|
|
406 |
int diff_reserved = (reserved_diff + malloc_diff + arena_diff);
|
|
407 |
|
|
408 |
// category summary
|
|
409 |
_output->print("-%26s (reserved=%d%s", MemBaseline::type2name(type),
|
|
410 |
total_reserved, unit);
|
|
411 |
|
|
412 |
if (diff_reserved != 0) {
|
|
413 |
_output->print(" %+d%s", diff_reserved, unit);
|
|
414 |
}
|
|
415 |
|
|
416 |
size_t total_committed = cur_committed_amt + cur_malloc_amt + cur_arena_amt;
|
|
417 |
_output->print(", committed=%d%s", total_committed, unit);
|
|
418 |
|
|
419 |
int total_committed_diff = committed_diff + malloc_diff + arena_diff;
|
|
420 |
if (total_committed_diff != 0) {
|
|
421 |
_output->print(" %+d%s", total_committed_diff, unit);
|
|
422 |
}
|
|
423 |
|
|
424 |
_output->print_cr(")");
|
|
425 |
|
|
426 |
// special cases
|
|
427 |
if (type == mtClass) {
|
|
428 |
_output->print("%27s (classes #%d", " ", _num_of_classes);
|
|
429 |
if (_num_of_classes_diff != 0) {
|
|
430 |
_output->print(" %+d", _num_of_classes_diff);
|
|
431 |
}
|
|
432 |
_output->print_cr(")");
|
|
433 |
} else if (type == mtThread) {
|
|
434 |
// thread count
|
|
435 |
_output->print("%27s (thread #%d", " ", _num_of_threads);
|
|
436 |
if (_num_of_threads_diff != 0) {
|
|
437 |
_output->print_cr(" %+d)", _num_of_threads_diff);
|
|
438 |
} else {
|
|
439 |
_output->print_cr(")");
|
|
440 |
}
|
|
441 |
_output->print("%27s (stack: reserved=%d%s", " ", _thread_stack_reserved, unit);
|
|
442 |
if (_thread_stack_reserved_diff != 0) {
|
|
443 |
_output->print(" %+d%s", _thread_stack_reserved_diff, unit);
|
|
444 |
}
|
|
445 |
|
|
446 |
_output->print(", committed=%d%s", _thread_stack_committed, unit);
|
|
447 |
if (_thread_stack_committed_diff != 0) {
|
|
448 |
_output->print(" %+d%s",_thread_stack_committed_diff, unit);
|
|
449 |
}
|
|
450 |
|
|
451 |
_output->print_cr(")");
|
|
452 |
}
|
|
453 |
|
|
454 |
// malloc'd memory
|
|
455 |
if (cur_malloc_amt > 0) {
|
|
456 |
_output->print("%27s (malloc=%d%s", " ", cur_malloc_amt, unit);
|
|
457 |
if (malloc_diff != 0) {
|
|
458 |
_output->print(" %+d%s", malloc_diff, unit);
|
|
459 |
}
|
|
460 |
if (type != mtChunk) {
|
|
461 |
_output->print(", #%d", cur_malloc_count);
|
|
462 |
if (malloc_count_diff) {
|
|
463 |
_output->print(" %+d", malloc_count_diff);
|
|
464 |
}
|
|
465 |
}
|
|
466 |
_output->print_cr(")");
|
|
467 |
}
|
|
468 |
|
|
469 |
// mmap'd memory
|
|
470 |
if (cur_reserved_amt > 0) {
|
|
471 |
_output->print("%27s (mmap: reserved=%d%s", " ", cur_reserved_amt, unit);
|
|
472 |
if (reserved_diff != 0) {
|
|
473 |
_output->print(" %+d%s", reserved_diff, unit);
|
|
474 |
}
|
|
475 |
|
|
476 |
_output->print(", committed=%d%s", cur_committed_amt, unit);
|
|
477 |
if (committed_diff != 0) {
|
|
478 |
_output->print(" %+d%s", committed_diff, unit);
|
|
479 |
}
|
|
480 |
_output->print_cr(")");
|
|
481 |
}
|
|
482 |
|
|
483 |
// arena memory
|
|
484 |
if (cur_arena_amt > 0) {
|
|
485 |
_output->print("%27s (arena=%d%s", " ", cur_arena_amt, unit);
|
|
486 |
if (arena_diff != 0) {
|
|
487 |
_output->print(" %+d%s", arena_diff, unit);
|
|
488 |
}
|
|
489 |
_output->print(", #%d", cur_arena_count);
|
|
490 |
if (arena_count_diff != 0) {
|
|
491 |
_output->print(" %+d", arena_count_diff);
|
|
492 |
}
|
|
493 |
_output->print_cr(")");
|
|
494 |
}
|
|
495 |
|
|
496 |
_output->print_cr(" ");
|
|
497 |
}
|
|
498 |
}
|
|
499 |
|
|
500 |
void BaselineTTYOutputer::diff_malloc_callsite(address pc,
|
|
501 |
size_t cur_malloc_amt, size_t cur_malloc_count,
|
|
502 |
int malloc_diff, int malloc_count_diff) {
|
|
503 |
if (malloc_diff != 0) {
|
|
504 |
const char* unit = memory_unit(_scale);
|
|
505 |
char buf[64];
|
|
506 |
int offset;
|
|
507 |
if (pc == 0) {
|
|
508 |
_output->print_cr("[BOOTSTRAP]%18s", " ");
|
|
509 |
} else {
|
|
510 |
if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) {
|
|
511 |
_output->print_cr("[" PTR_FORMAT "] %s+0x%x", pc, buf, offset);
|
|
512 |
_output->print("%28s", " ");
|
|
513 |
} else {
|
|
514 |
_output->print("[" PTR_FORMAT "]%18s", pc, " ");
|
|
515 |
}
|
|
516 |
}
|
|
517 |
|
|
518 |
_output->print("(malloc=%d%s", cur_malloc_amt, unit);
|
|
519 |
if (malloc_diff != 0) {
|
|
520 |
_output->print(" %+d%s", malloc_diff, unit);
|
|
521 |
}
|
|
522 |
_output->print(", #%d", cur_malloc_count);
|
|
523 |
if (malloc_count_diff != 0) {
|
|
524 |
_output->print(" %+d", malloc_count_diff);
|
|
525 |
}
|
|
526 |
_output->print_cr(")");
|
|
527 |
_output->print_cr(" ");
|
|
528 |
}
|
|
529 |
}
|
|
530 |
|
|
531 |
void BaselineTTYOutputer::diff_virtual_memory_callsite(address pc,
|
|
532 |
size_t cur_reserved_amt, size_t cur_committed_amt,
|
|
533 |
int reserved_diff, int committed_diff) {
|
|
534 |
if (reserved_diff != 0 || committed_diff != 0) {
|
|
535 |
const char* unit = memory_unit(_scale);
|
|
536 |
char buf[64];
|
|
537 |
int offset;
|
|
538 |
if (pc == 0) {
|
|
539 |
_output->print_cr("[BOOSTRAP]%18s", " ");
|
|
540 |
} else {
|
|
541 |
if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) {
|
|
542 |
_output->print_cr("[" PTR_FORMAT "] %s+0x%x", pc, buf, offset);
|
|
543 |
_output->print("%28s", " ");
|
|
544 |
} else {
|
|
545 |
_output->print("[" PTR_FORMAT "]%18s", " ");
|
|
546 |
}
|
|
547 |
}
|
|
548 |
|
|
549 |
_output->print("(mmap: reserved=%d%s", cur_reserved_amt, unit);
|
|
550 |
if (reserved_diff != 0) {
|
|
551 |
_output->print(" %+d%s", reserved_diff, unit);
|
|
552 |
}
|
|
553 |
_output->print(", committed=%d%s", cur_committed_amt, unit);
|
|
554 |
if (committed_diff != 0) {
|
|
555 |
_output->print(" %+d%s", committed_diff, unit);
|
|
556 |
}
|
|
557 |
_output->print_cr(")");
|
|
558 |
_output->print_cr(" ");
|
|
559 |
}
|
|
560 |
}
|