310 _current_baseline.virtual_memory(flag)); |
310 _current_baseline.virtual_memory(flag)); |
311 } |
311 } |
312 } |
312 } |
313 |
313 |
314 void MemSummaryDiffReporter::print_malloc_diff(size_t current_amount, size_t current_count, |
314 void MemSummaryDiffReporter::print_malloc_diff(size_t current_amount, size_t current_count, |
315 size_t early_amount, size_t early_count) const { |
315 size_t early_amount, size_t early_count, MEMFLAGS flags) const { |
316 const char* scale = current_scale(); |
316 const char* scale = current_scale(); |
317 outputStream* out = output(); |
317 outputStream* out = output(); |
318 |
318 |
319 out->print("malloc=" SIZE_FORMAT "%s", amount_in_current_scale(current_amount), scale); |
319 out->print("malloc=" SIZE_FORMAT "%s", amount_in_current_scale(current_amount), scale); |
|
320 // Report type only if it is valid |
|
321 if (flags != mtNone) { |
|
322 out->print(" type=%s", NMTUtil::flag_to_name(flags)); |
|
323 } |
|
324 |
320 long amount_diff = diff_in_current_scale(current_amount, early_amount); |
325 long amount_diff = diff_in_current_scale(current_amount, early_amount); |
321 if (amount_diff != 0) { |
326 if (amount_diff != 0) { |
322 out->print(" %+ld%s", amount_diff, scale); |
327 out->print(" %+ld%s", amount_diff, scale); |
323 } |
328 } |
324 if (current_count > 0) { |
329 if (current_count > 0) { |
443 size_t early_malloc_amount = early_malloc->malloc_size(); |
448 size_t early_malloc_amount = early_malloc->malloc_size(); |
444 if (amount_in_current_scale(current_malloc_amount) > 0 || |
449 if (amount_in_current_scale(current_malloc_amount) > 0 || |
445 diff_in_current_scale(current_malloc_amount, early_malloc_amount) != 0) { |
450 diff_in_current_scale(current_malloc_amount, early_malloc_amount) != 0) { |
446 out->print("%28s(", " "); |
451 out->print("%28s(", " "); |
447 print_malloc_diff(current_malloc_amount, (flag == mtChunk) ? 0 : current_malloc->malloc_count(), |
452 print_malloc_diff(current_malloc_amount, (flag == mtChunk) ? 0 : current_malloc->malloc_count(), |
448 early_malloc_amount, early_malloc->malloc_count()); |
453 early_malloc_amount, early_malloc->malloc_count(), mtNone); |
449 out->print_cr(")"); |
454 out->print_cr(")"); |
450 } |
455 } |
451 |
456 |
452 // Report virtual memory |
457 // Report virtual memory |
453 if (amount_in_current_scale(current_vm->reserved()) > 0 || |
458 if (amount_in_current_scale(current_vm->reserved()) > 0 || |
491 diff_malloc_sites(); |
496 diff_malloc_sites(); |
492 diff_virtual_memory_sites(); |
497 diff_virtual_memory_sites(); |
493 } |
498 } |
494 |
499 |
495 void MemDetailDiffReporter::diff_malloc_sites() const { |
500 void MemDetailDiffReporter::diff_malloc_sites() const { |
496 MallocSiteIterator early_itr = _early_baseline.malloc_sites(MemBaseline::by_site); |
501 MallocSiteIterator early_itr = _early_baseline.malloc_sites(MemBaseline::by_site_and_type); |
497 MallocSiteIterator current_itr = _current_baseline.malloc_sites(MemBaseline::by_site); |
502 MallocSiteIterator current_itr = _current_baseline.malloc_sites(MemBaseline::by_site_and_type); |
498 |
503 |
499 const MallocSite* early_site = early_itr.next(); |
504 const MallocSite* early_site = early_itr.next(); |
500 const MallocSite* current_site = current_itr.next(); |
505 const MallocSite* current_site = current_itr.next(); |
501 |
506 |
502 while (early_site != NULL || current_site != NULL) { |
507 while (early_site != NULL || current_site != NULL) { |
555 } |
560 } |
556 |
561 |
557 |
562 |
558 void MemDetailDiffReporter::new_malloc_site(const MallocSite* malloc_site) const { |
563 void MemDetailDiffReporter::new_malloc_site(const MallocSite* malloc_site) const { |
559 diff_malloc_site(malloc_site->call_stack(), malloc_site->size(), malloc_site->count(), |
564 diff_malloc_site(malloc_site->call_stack(), malloc_site->size(), malloc_site->count(), |
560 0, 0); |
565 0, 0, malloc_site->flags()); |
561 } |
566 } |
562 |
567 |
563 void MemDetailDiffReporter::old_malloc_site(const MallocSite* malloc_site) const { |
568 void MemDetailDiffReporter::old_malloc_site(const MallocSite* malloc_site) const { |
564 diff_malloc_site(malloc_site->call_stack(), 0, 0, malloc_site->size(), |
569 diff_malloc_site(malloc_site->call_stack(), 0, 0, malloc_site->size(), |
565 malloc_site->count()); |
570 malloc_site->count(), malloc_site->flags()); |
566 } |
571 } |
567 |
572 |
568 void MemDetailDiffReporter::diff_malloc_site(const MallocSite* early, |
573 void MemDetailDiffReporter::diff_malloc_site(const MallocSite* early, |
569 const MallocSite* current) const { |
574 const MallocSite* current) const { |
|
575 assert(early->flags() == current->flags(), "Must be the same memory type"); |
570 diff_malloc_site(current->call_stack(), current->size(), current->count(), |
576 diff_malloc_site(current->call_stack(), current->size(), current->count(), |
571 early->size(), early->count()); |
577 early->size(), early->count(), early->flags()); |
572 } |
578 } |
573 |
579 |
574 void MemDetailDiffReporter::diff_malloc_site(const NativeCallStack* stack, size_t current_size, |
580 void MemDetailDiffReporter::diff_malloc_site(const NativeCallStack* stack, size_t current_size, |
575 size_t current_count, size_t early_size, size_t early_count) const { |
581 size_t current_count, size_t early_size, size_t early_count, MEMFLAGS flags) const { |
576 outputStream* out = output(); |
582 outputStream* out = output(); |
577 |
583 |
578 assert(stack != NULL, "NULL stack"); |
584 assert(stack != NULL, "NULL stack"); |
579 |
585 |
580 if (diff_in_current_scale(current_size, early_size) == 0) { |
586 if (diff_in_current_scale(current_size, early_size) == 0) { |
582 } |
588 } |
583 |
589 |
584 stack->print_on(out); |
590 stack->print_on(out); |
585 out->print("%28s (", " "); |
591 out->print("%28s (", " "); |
586 print_malloc_diff(current_size, current_count, |
592 print_malloc_diff(current_size, current_count, |
587 early_size, early_count); |
593 early_size, early_count, flags); |
588 |
594 |
589 out->print_cr(")\n"); |
595 out->print_cr(")\n"); |
590 } |
596 } |
591 |
597 |
592 |
598 |