diff -r 65a0cf59bfd8 -r ec4a84ba2aaf src/hotspot/share/services/virtualMemoryTracker.cpp --- a/src/hotspot/share/services/virtualMemoryTracker.cpp Tue Jan 30 10:38:17 2018 +0100 +++ b/src/hotspot/share/services/virtualMemoryTracker.cpp Tue Jan 30 16:26:40 2018 +0100 @@ -65,26 +65,16 @@ } if (rgn->adjacent_to(addr, size)) { - if (rgn->call_stack()->equals(stack)) { + // special case to expand prior region if there is no next region + LinkedListNode* next = node->next(); + if (next == NULL && rgn->call_stack()->equals(stack)) { + VirtualMemorySummary::record_uncommitted_memory(rgn->size(), flag()); // the two adjacent regions have the same call stack, merge them rgn->expand_region(addr, size); - VirtualMemorySummary::record_committed_memory(size, flag()); - - // maybe merge with the next region - LinkedListNode* next_node = node->next(); - if (next_node != NULL) { - CommittedMemoryRegion* next = next_node->data(); - if (next->call_stack()->equals(stack) && rgn->adjacent_to(next->base(), next->size())) { - // the two adjacent regions have the same call stack, merge them - rgn->expand_region(next->base(), next->size()); - - // the merge next_node needs to be removed from the list - _committed_regions.remove(next_node); - } - } + VirtualMemorySummary::record_committed_memory(rgn->size(), flag()); return true; } - } + } if (rgn->overlap_region(addr, size)) { // Clear a space for this region in the case it overlaps with any regions. @@ -97,10 +87,10 @@ node = node->next(); } - // New committed region - VirtualMemorySummary::record_committed_memory(size, flag()); - return add_committed_region(committed_rgn); -} + // New committed region + VirtualMemorySummary::record_committed_memory(size, flag()); + return add_committed_region(committed_rgn); + } void ReservedMemoryRegion::set_all_committed(bool b) { if (all_committed() != b) {