173 |
173 |
174 if (flag == mtNMT && |
174 if (flag == mtNMT && |
175 amount_in_current_scale(_malloc_snapshot->malloc_overhead()->size()) > 0) { |
175 amount_in_current_scale(_malloc_snapshot->malloc_overhead()->size()) > 0) { |
176 out->print_cr("%27s (tracking overhead=" SIZE_FORMAT "%s)", " ", |
176 out->print_cr("%27s (tracking overhead=" SIZE_FORMAT "%s)", " ", |
177 amount_in_current_scale(_malloc_snapshot->malloc_overhead()->size()), scale); |
177 amount_in_current_scale(_malloc_snapshot->malloc_overhead()->size()), scale); |
178 } |
178 } else if (flag == mtClass) { |
179 |
179 // Metadata information |
|
180 report_metadata(Metaspace::NonClassType); |
|
181 if (Metaspace::using_class_space()) { |
|
182 report_metadata(Metaspace::ClassType); |
|
183 } |
|
184 } |
180 out->print_cr(" "); |
185 out->print_cr(" "); |
181 } |
186 } |
|
187 } |
|
188 |
|
189 void MemSummaryReporter::report_metadata(Metaspace::MetadataType type) const { |
|
190 assert(type == Metaspace::NonClassType || type == Metaspace::ClassType, |
|
191 "Invalid metadata type"); |
|
192 const char* name = (type == Metaspace::NonClassType) ? |
|
193 "Metadata: " : "Class space:"; |
|
194 |
|
195 outputStream* out = output(); |
|
196 const char* scale = current_scale(); |
|
197 size_t committed = MetaspaceAux::committed_bytes(type); |
|
198 size_t used = MetaspaceAux::used_bytes(type); |
|
199 size_t free = (MetaspaceAux::capacity_bytes(type) - used) |
|
200 + MetaspaceAux::free_chunks_total_bytes(type) |
|
201 + MetaspaceAux::free_bytes(type); |
|
202 |
|
203 assert(committed >= used + free, "Sanity"); |
|
204 size_t waste = committed - (used + free); |
|
205 |
|
206 out->print_cr("%27s ( %s)", " ", name); |
|
207 out->print("%27s ( ", " "); |
|
208 print_total(MetaspaceAux::reserved_bytes(type), committed); |
|
209 out->print_cr(")"); |
|
210 out->print_cr("%27s ( used=" SIZE_FORMAT "%s)", " ", amount_in_current_scale(used), scale); |
|
211 out->print_cr("%27s ( free=" SIZE_FORMAT "%s)", " ", amount_in_current_scale(free), scale); |
|
212 out->print_cr("%27s ( waste=" SIZE_FORMAT "%s =%2.2f%%)", " ", amount_in_current_scale(waste), |
|
213 scale, ((float)waste * 100)/committed); |
182 } |
214 } |
183 |
215 |
184 void MemDetailReporter::report_detail() { |
216 void MemDetailReporter::report_detail() { |
185 // Start detail report |
217 // Start detail report |
186 outputStream* out = output(); |
218 outputStream* out = output(); |
303 // Summary diff by memory type |
335 // Summary diff by memory type |
304 for (int index = 0; index < mt_number_of_types; index ++) { |
336 for (int index = 0; index < mt_number_of_types; index ++) { |
305 MEMFLAGS flag = NMTUtil::index_to_flag(index); |
337 MEMFLAGS flag = NMTUtil::index_to_flag(index); |
306 // thread stack is reported as part of thread category |
338 // thread stack is reported as part of thread category |
307 if (flag == mtThreadStack) continue; |
339 if (flag == mtThreadStack) continue; |
308 diff_summary_of_type(flag, _early_baseline.malloc_memory(flag), |
340 diff_summary_of_type(flag, |
309 _early_baseline.virtual_memory(flag), _current_baseline.malloc_memory(flag), |
341 _early_baseline.malloc_memory(flag), |
310 _current_baseline.virtual_memory(flag)); |
342 _early_baseline.virtual_memory(flag), |
|
343 _early_baseline.metaspace_snapshot(), |
|
344 _current_baseline.malloc_memory(flag), |
|
345 _current_baseline.virtual_memory(flag), |
|
346 _current_baseline.metaspace_snapshot()); |
311 } |
347 } |
312 } |
348 } |
313 |
349 |
314 void MemSummaryDiffReporter::print_malloc_diff(size_t current_amount, size_t current_count, |
350 void MemSummaryDiffReporter::print_malloc_diff(size_t current_amount, size_t current_count, |
315 size_t early_amount, size_t early_count, MEMFLAGS flags) const { |
351 size_t early_amount, size_t early_count, MEMFLAGS flags) const { |
365 out->print(" %+ld%s", committed_diff, scale); |
401 out->print(" %+ld%s", committed_diff, scale); |
366 } |
402 } |
367 } |
403 } |
368 |
404 |
369 |
405 |
370 void MemSummaryDiffReporter::diff_summary_of_type(MEMFLAGS flag, const MallocMemory* early_malloc, |
406 void MemSummaryDiffReporter::diff_summary_of_type(MEMFLAGS flag, |
371 const VirtualMemory* early_vm, const MallocMemory* current_malloc, |
407 const MallocMemory* early_malloc, const VirtualMemory* early_vm, |
372 const VirtualMemory* current_vm) const { |
408 const MetaspaceSnapshot* early_ms, |
|
409 const MallocMemory* current_malloc, const VirtualMemory* current_vm, |
|
410 const MetaspaceSnapshot* current_ms) const { |
373 |
411 |
374 outputStream* out = output(); |
412 outputStream* out = output(); |
375 const char* scale = current_scale(); |
413 const char* scale = current_scale(); |
376 |
414 |
377 // Total reserved and committed memory in current baseline |
415 // Total reserved and committed memory in current baseline |
484 _early_baseline.malloc_tracking_overhead()); |
522 _early_baseline.malloc_tracking_overhead()); |
485 if (overhead_diff != 0) { |
523 if (overhead_diff != 0) { |
486 out->print(" %+ld%s", overhead_diff, scale); |
524 out->print(" %+ld%s", overhead_diff, scale); |
487 } |
525 } |
488 out->print_cr(")"); |
526 out->print_cr(")"); |
|
527 } else if (flag == mtClass) { |
|
528 assert(current_ms != NULL && early_ms != NULL, "Sanity"); |
|
529 print_metaspace_diff(current_ms, early_ms); |
489 } |
530 } |
490 out->print_cr(" "); |
531 out->print_cr(" "); |
491 } |
532 } |
|
533 } |
|
534 |
|
535 void MemSummaryDiffReporter::print_metaspace_diff(const MetaspaceSnapshot* current_ms, |
|
536 const MetaspaceSnapshot* early_ms) const { |
|
537 print_metaspace_diff(Metaspace::NonClassType, current_ms, early_ms); |
|
538 if (Metaspace::using_class_space()) { |
|
539 print_metaspace_diff(Metaspace::ClassType, current_ms, early_ms); |
|
540 } |
|
541 } |
|
542 |
|
543 void MemSummaryDiffReporter::print_metaspace_diff(Metaspace::MetadataType type, |
|
544 const MetaspaceSnapshot* current_ms, |
|
545 const MetaspaceSnapshot* early_ms) const { |
|
546 const char* name = (type == Metaspace::NonClassType) ? |
|
547 "Metadata: " : "Class space:"; |
|
548 |
|
549 outputStream* out = output(); |
|
550 const char* scale = current_scale(); |
|
551 |
|
552 out->print_cr("%27s ( %s)", " ", name); |
|
553 out->print("%27s ( ", " "); |
|
554 print_virtual_memory_diff(current_ms->reserved_in_bytes(type), |
|
555 current_ms->committed_in_bytes(type), |
|
556 early_ms->reserved_in_bytes(type), |
|
557 early_ms->committed_in_bytes(type)); |
|
558 out->print_cr(")"); |
|
559 |
|
560 long diff_used = diff_in_current_scale(current_ms->used_in_bytes(type), |
|
561 early_ms->used_in_bytes(type)); |
|
562 long diff_free = diff_in_current_scale(current_ms->free_in_bytes(type), |
|
563 early_ms->free_in_bytes(type)); |
|
564 |
|
565 size_t current_waste = current_ms->committed_in_bytes(type) |
|
566 - (current_ms->used_in_bytes(type) + current_ms->free_in_bytes(type)); |
|
567 size_t early_waste = early_ms->committed_in_bytes(type) |
|
568 - (early_ms->used_in_bytes(type) + early_ms->free_in_bytes(type)); |
|
569 long diff_waste = diff_in_current_scale(current_waste, early_waste); |
|
570 |
|
571 // Diff used |
|
572 out->print("%27s ( used=" SIZE_FORMAT "%s", " ", |
|
573 amount_in_current_scale(current_ms->used_in_bytes(type)), scale); |
|
574 if (diff_used != 0) { |
|
575 out->print(" %+ld%s", diff_used, scale); |
|
576 } |
|
577 out->print_cr(")"); |
|
578 |
|
579 // Diff free |
|
580 out->print("%27s ( free=" SIZE_FORMAT "%s", " ", |
|
581 amount_in_current_scale(current_ms->free_in_bytes(type)), scale); |
|
582 if (diff_free != 0) { |
|
583 out->print(" %+ld%s", diff_free, scale); |
|
584 } |
|
585 out->print_cr(")"); |
|
586 |
|
587 |
|
588 // Diff waste |
|
589 out->print("%27s ( waste=" SIZE_FORMAT "%s =%2.2f%%", " ", |
|
590 amount_in_current_scale(current_waste), scale, |
|
591 ((float)current_waste * 100) / current_ms->committed_in_bytes(type)); |
|
592 if (diff_waste != 0) { |
|
593 out->print(" %+ld%s", diff_waste, scale); |
|
594 } |
|
595 out->print_cr(")"); |
492 } |
596 } |
493 |
597 |
494 void MemDetailDiffReporter::report_diff() { |
598 void MemDetailDiffReporter::report_diff() { |
495 MemSummaryDiffReporter::report_diff(); |
599 MemSummaryDiffReporter::report_diff(); |
496 diff_malloc_sites(); |
600 diff_malloc_sites(); |