198 amount_in_current_scale(_malloc_snapshot->malloc_overhead()->size()) > 0) { |
198 amount_in_current_scale(_malloc_snapshot->malloc_overhead()->size()) > 0) { |
199 out->print_cr("%27s (tracking overhead=" SIZE_FORMAT "%s)", " ", |
199 out->print_cr("%27s (tracking overhead=" SIZE_FORMAT "%s)", " ", |
200 amount_in_current_scale(_malloc_snapshot->malloc_overhead()->size()), scale); |
200 amount_in_current_scale(_malloc_snapshot->malloc_overhead()->size()), scale); |
201 } else if (flag == mtClass) { |
201 } else if (flag == mtClass) { |
202 // Metadata information |
202 // Metadata information |
203 report_metadata(Metaspace::NonClassType); |
203 report_metadata(metaspace::NonClassType); |
204 if (Metaspace::using_class_space()) { |
204 if (Metaspace::using_class_space()) { |
205 report_metadata(Metaspace::ClassType); |
205 report_metadata(metaspace::ClassType); |
206 } |
206 } |
207 } |
207 } |
208 out->print_cr(" "); |
208 out->print_cr(" "); |
209 } |
209 } |
210 } |
210 } |
211 |
211 |
212 void MemSummaryReporter::report_metadata(Metaspace::MetadataType type) const { |
212 void MemSummaryReporter::report_metadata(metaspace::MetadataType mdType) const { |
213 assert(type == Metaspace::NonClassType || type == Metaspace::ClassType, |
213 DEBUG_ONLY(metaspace::check_valid_mdtype(mdType)); |
214 "Invalid metadata type"); |
214 const char* const name = metaspace::describe_mdtype(mdType); |
215 const char* name = (type == Metaspace::NonClassType) ? |
215 |
216 "Metadata: " : "Class space:"; |
216 outputStream* out = output(); |
217 |
217 const char* scale = current_scale(); |
218 outputStream* out = output(); |
218 size_t committed = MetaspaceUtils::committed_bytes(mdType); |
219 const char* scale = current_scale(); |
219 size_t used = MetaspaceUtils::used_bytes(mdType); |
220 size_t committed = MetaspaceUtils::committed_bytes(type); |
220 size_t free = 0; // |
221 size_t used = MetaspaceUtils::used_bytes(type); |
221 // TODO think this thru. What is free in this context? |
222 size_t free = (MetaspaceUtils::capacity_bytes(type) - used) |
222 // (MetaspaceUtils::capacity_bytes(type) - used) |
223 + MetaspaceUtils::free_chunks_total_bytes(type) |
223 // + MetaspaceUtils::free_chunks_total_bytes(type) |
224 + MetaspaceUtils::free_in_vs_bytes(type); |
224 // + MetaspaceUtils::free_in_vs_bytes(type); |
225 |
225 |
226 assert(committed >= used + free, "Sanity"); |
226 assert(committed >= used + free, "Sanity"); |
227 size_t waste = committed - (used + free); |
227 size_t waste = committed - (used + free); |
228 |
228 |
229 out->print_cr("%27s ( %s)", " ", name); |
229 out->print_cr("%27s ( %s)", " ", name); |
230 out->print("%27s ( ", " "); |
230 out->print("%27s ( ", " "); |
231 print_total(MetaspaceUtils::reserved_bytes(type), committed); |
231 print_total(MetaspaceUtils::reserved_bytes(mdType), committed); |
232 out->print_cr(")"); |
232 out->print_cr(")"); |
233 out->print_cr("%27s ( used=" SIZE_FORMAT "%s)", " ", amount_in_current_scale(used), scale); |
233 out->print_cr("%27s ( used=" SIZE_FORMAT "%s)", " ", amount_in_current_scale(used), scale); |
234 out->print_cr("%27s ( free=" SIZE_FORMAT "%s)", " ", amount_in_current_scale(free), scale); |
234 out->print_cr("%27s ( free=" SIZE_FORMAT "%s)", " ", amount_in_current_scale(free), scale); |
235 out->print_cr("%27s ( waste=" SIZE_FORMAT "%s =%2.2f%%)", " ", amount_in_current_scale(waste), |
235 out->print_cr("%27s ( waste=" SIZE_FORMAT "%s =%2.2f%%)", " ", amount_in_current_scale(waste), |
236 scale, ((float)waste * 100)/committed); |
236 scale, ((float)waste * 100)/committed); |
591 } |
591 } |
592 } |
592 } |
593 |
593 |
594 void MemSummaryDiffReporter::print_metaspace_diff(const MetaspaceSnapshot* current_ms, |
594 void MemSummaryDiffReporter::print_metaspace_diff(const MetaspaceSnapshot* current_ms, |
595 const MetaspaceSnapshot* early_ms) const { |
595 const MetaspaceSnapshot* early_ms) const { |
596 print_metaspace_diff(Metaspace::NonClassType, current_ms, early_ms); |
596 print_metaspace_diff(metaspace::NonClassType, current_ms, early_ms); |
597 if (Metaspace::using_class_space()) { |
597 if (Metaspace::using_class_space()) { |
598 print_metaspace_diff(Metaspace::ClassType, current_ms, early_ms); |
598 print_metaspace_diff(metaspace::ClassType, current_ms, early_ms); |
599 } |
599 } |
600 } |
600 } |
601 |
601 |
602 void MemSummaryDiffReporter::print_metaspace_diff(Metaspace::MetadataType type, |
602 void MemSummaryDiffReporter::print_metaspace_diff(metaspace::MetadataType mdType, |
603 const MetaspaceSnapshot* current_ms, |
603 const MetaspaceSnapshot* current_ms, |
604 const MetaspaceSnapshot* early_ms) const { |
604 const MetaspaceSnapshot* early_ms) const { |
605 const char* name = (type == Metaspace::NonClassType) ? |
605 DEBUG_ONLY(metaspace::check_valid_mdtype(mdType)); |
606 "Metadata: " : "Class space:"; |
606 const char* const name = metaspace::describe_mdtype(mdType); |
607 |
607 |
608 outputStream* out = output(); |
608 outputStream* out = output(); |
609 const char* scale = current_scale(); |
609 const char* scale = current_scale(); |
610 |
610 |
611 out->print_cr("%27s ( %s)", " ", name); |
611 out->print_cr("%27s ( %s)", " ", name); |
612 out->print("%27s ( ", " "); |
612 out->print("%27s ( ", " "); |
613 print_virtual_memory_diff(current_ms->reserved_in_bytes(type), |
613 print_virtual_memory_diff(current_ms->reserved_in_bytes(mdType), |
614 current_ms->committed_in_bytes(type), |
614 current_ms->committed_in_bytes(mdType), |
615 early_ms->reserved_in_bytes(type), |
615 early_ms->reserved_in_bytes(mdType), |
616 early_ms->committed_in_bytes(type)); |
616 early_ms->committed_in_bytes(mdType)); |
617 out->print_cr(")"); |
617 out->print_cr(")"); |
618 |
618 |
619 long diff_used = diff_in_current_scale(current_ms->used_in_bytes(type), |
619 long diff_used = diff_in_current_scale(current_ms->used_in_bytes(mdType), |
620 early_ms->used_in_bytes(type)); |
620 early_ms->used_in_bytes(mdType)); |
621 long diff_free = diff_in_current_scale(current_ms->free_in_bytes(type), |
621 long diff_free = diff_in_current_scale(current_ms->free_in_bytes(mdType), |
622 early_ms->free_in_bytes(type)); |
622 early_ms->free_in_bytes(mdType)); |
623 |
623 |
624 size_t current_waste = current_ms->committed_in_bytes(type) |
624 size_t current_waste = current_ms->committed_in_bytes(mdType) |
625 - (current_ms->used_in_bytes(type) + current_ms->free_in_bytes(type)); |
625 - (current_ms->used_in_bytes(mdType) + current_ms->free_in_bytes(mdType)); |
626 size_t early_waste = early_ms->committed_in_bytes(type) |
626 size_t early_waste = early_ms->committed_in_bytes(mdType) |
627 - (early_ms->used_in_bytes(type) + early_ms->free_in_bytes(type)); |
627 - (early_ms->used_in_bytes(mdType) + early_ms->free_in_bytes(mdType)); |
628 long diff_waste = diff_in_current_scale(current_waste, early_waste); |
628 long diff_waste = diff_in_current_scale(current_waste, early_waste); |
629 |
629 |
630 // Diff used |
630 // Diff used |
631 out->print("%27s ( used=" SIZE_FORMAT "%s", " ", |
631 out->print("%27s ( used=" SIZE_FORMAT "%s", " ", |
632 amount_in_current_scale(current_ms->used_in_bytes(type)), scale); |
632 amount_in_current_scale(current_ms->used_in_bytes(mdType)), scale); |
633 if (diff_used != 0) { |
633 if (diff_used != 0) { |
634 out->print(" %+ld%s", diff_used, scale); |
634 out->print(" %+ld%s", diff_used, scale); |
635 } |
635 } |
636 out->print_cr(")"); |
636 out->print_cr(")"); |
637 |
637 |
638 // Diff free |
638 // Diff free |
639 out->print("%27s ( free=" SIZE_FORMAT "%s", " ", |
639 out->print("%27s ( free=" SIZE_FORMAT "%s", " ", |
640 amount_in_current_scale(current_ms->free_in_bytes(type)), scale); |
640 amount_in_current_scale(current_ms->free_in_bytes(mdType)), scale); |
641 if (diff_free != 0) { |
641 if (diff_free != 0) { |
642 out->print(" %+ld%s", diff_free, scale); |
642 out->print(" %+ld%s", diff_free, scale); |
643 } |
643 } |
644 out->print_cr(")"); |
644 out->print_cr(")"); |
645 |
645 |
646 |
646 |
647 // Diff waste |
647 // Diff waste |
648 out->print("%27s ( waste=" SIZE_FORMAT "%s =%2.2f%%", " ", |
648 out->print("%27s ( waste=" SIZE_FORMAT "%s =%2.2f%%", " ", |
649 amount_in_current_scale(current_waste), scale, |
649 amount_in_current_scale(current_waste), scale, |
650 ((float)current_waste * 100) / current_ms->committed_in_bytes(type)); |
650 ((float)current_waste * 100) / current_ms->committed_in_bytes(mdType)); |
651 if (diff_waste != 0) { |
651 if (diff_waste != 0) { |
652 out->print(" %+ld%s", diff_waste, scale); |
652 out->print(" %+ld%s", diff_waste, scale); |
653 } |
653 } |
654 out->print_cr(")"); |
654 out->print_cr(")"); |
655 } |
655 } |