|
22 | 22 | *
|
23 | 23 | */
|
24 | 24 | #include "cds/filemap.hpp"
|
| 25 | +#include "logging/log.hpp" |
25 | 26 | #include "memory/metaspace.hpp"
|
26 | 27 | #include "memory/metaspaceUtils.hpp"
|
27 | 28 | #include "nmt/mallocTracker.hpp"
|
28 | 29 | #include "nmt/memTag.hpp"
|
29 | 30 | #include "nmt/memReporter.hpp"
|
30 | 31 | #include "nmt/memTracker.hpp"
|
31 | 32 | #include "nmt/memoryFileTracker.hpp"
|
| 33 | +#include "nmt/regionsTree.hpp" |
| 34 | +#include "nmt/regionsTree.inline.hpp" |
32 | 35 | #include "nmt/threadStackTracker.hpp"
|
33 | 36 | #include "nmt/virtualMemoryTracker.hpp"
|
34 | 37 | #include "utilities/debug.hpp"
|
@@ -432,34 +435,45 @@ void MemDetailReporter::report_virtual_memory_region(const ReservedMemoryRegion*
|
432 | 435 | }
|
433 | 436 |
|
434 | 437 | if (all_committed) {
|
435 |
| - CommittedRegionIterator itr = reserved_rgn->iterate_committed_regions(); |
436 |
| - const CommittedMemoryRegion* committed_rgn = itr.next(); |
437 |
| - if (committed_rgn->size() == reserved_rgn->size() && committed_rgn->call_stack()->equals(*stack)) { |
438 |
| - // One region spanning the entire reserved region, with the same stack trace. |
439 |
| - // Don't print this regions because the "reserved and committed" line above |
440 |
| - // already indicates that the region is committed. |
441 |
| - assert(itr.next() == nullptr, "Unexpectedly more than one regions"); |
| 438 | + bool reserved_and_committed = false; |
| 439 | + VirtualMemoryTracker::Instance::tree()->visit_committed_regions(*reserved_rgn, |
| 440 | + [&](CommittedMemoryRegion& committed_rgn) { |
| 441 | + if (committed_rgn.equals(*reserved_rgn)) { |
| 442 | + // One region spanning the entire reserved region, with the same stack trace. |
| 443 | + // Don't print this regions because the "reserved and committed" line above |
| 444 | + // already indicates that the region is committed. |
| 445 | + reserved_and_committed = true; |
| 446 | + return false; |
| 447 | + } |
| 448 | + return true; |
| 449 | + }); |
| 450 | + |
| 451 | + if (reserved_and_committed) { |
442 | 452 | return;
|
443 | 453 | }
|
444 | 454 | }
|
445 | 455 |
|
446 |
| - CommittedRegionIterator itr = reserved_rgn->iterate_committed_regions(); |
447 |
| - const CommittedMemoryRegion* committed_rgn; |
448 |
| - while ((committed_rgn = itr.next()) != nullptr) { |
| 456 | + auto print_committed_rgn = [&](const CommittedMemoryRegion& crgn) { |
449 | 457 | // Don't report if size is too small
|
450 |
| - if (amount_in_current_scale(committed_rgn->size()) == 0) continue; |
451 |
| - stack = committed_rgn->call_stack(); |
| 458 | + if (amount_in_current_scale(crgn.size()) == 0) return; |
| 459 | + stack = crgn.call_stack(); |
452 | 460 | out->cr();
|
453 | 461 | INDENT_BY(8,
|
454 |
| - print_virtual_memory_region("committed", committed_rgn->base(), committed_rgn->size()); |
| 462 | + print_virtual_memory_region("committed", crgn.base(), crgn.size()); |
455 | 463 | if (stack->is_empty()) {
|
456 | 464 | out->cr();
|
457 | 465 | } else {
|
458 | 466 | out->print_cr(" from");
|
459 |
| - INDENT_BY(4, stack->print_on(out);) |
| 467 | + INDENT_BY(4, _stackprinter.print_stack(stack);) |
460 | 468 | }
|
461 | 469 | )
|
462 |
| - } |
| 470 | + }; |
| 471 | + |
| 472 | + VirtualMemoryTracker::Instance::tree()->visit_committed_regions(*reserved_rgn, |
| 473 | + [&](CommittedMemoryRegion& crgn) { |
| 474 | + print_committed_rgn(crgn); |
| 475 | + return true; |
| 476 | + }); |
463 | 477 | }
|
464 | 478 |
|
465 | 479 | void MemDetailReporter::report_memory_file_allocations() {
|
|
0 commit comments