From 4273487ee2d4324a48140cf9a548fb1f3f3fe08a Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Fri, 4 Aug 2023 11:33:06 +0000 Subject: [PATCH] 8313593: Generational ZGC: NMT assert when the heap fails to expand Reviewed-by: eosterlund Backport-of: 19e2c8c321823c056091e6e9f6c3d0db7ba9ec2b --- src/hotspot/share/gc/z/zPhysicalMemory.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/gc/z/zPhysicalMemory.cpp b/src/hotspot/share/gc/z/zPhysicalMemory.cpp index c0e0e837c9c..924bc729124 100644 --- a/src/hotspot/share/gc/z/zPhysicalMemory.cpp +++ b/src/hotspot/share/gc/z/zPhysicalMemory.cpp @@ -309,7 +309,9 @@ bool ZPhysicalMemoryManager::commit(ZPhysicalMemory& pmem) { const size_t committed = _backing.commit(segment.start(), segment.size()); // Register with NMT - ZNMT::commit(segment.start(), committed); + if (committed > 0) { + ZNMT::commit(segment.start(), committed); + } // Register committed segment if (!pmem.commit_segment(i, committed)) { @@ -335,7 +337,9 @@ bool ZPhysicalMemoryManager::uncommit(ZPhysicalMemory& pmem) { const size_t uncommitted = _backing.uncommit(segment.start(), segment.size()); // Unregister with NMT - ZNMT::uncommit(segment.start(), uncommitted); + if (uncommitted > 0) { + ZNMT::uncommit(segment.start(), uncommitted); + } // Deregister uncommitted segment if (!pmem.uncommit_segment(i, uncommitted)) {