8220591: ZGC: Don't delay reclaimation of ZVirtualMemory
authorpliden
Mon, 18 Mar 2019 11:50:39 +0100
changeset 54166 b9f030844be4
parent 54165 84295bd6d359
child 54167 d0d26fc836dd
8220591: ZGC: Don't delay reclaimation of ZVirtualMemory Reviewed-by: stefank, eosterlund
src/hotspot/share/gc/z/zPageAllocator.cpp
--- a/src/hotspot/share/gc/z/zPageAllocator.cpp	Mon Mar 18 11:50:39 2019 +0100
+++ b/src/hotspot/share/gc/z/zPageAllocator.cpp	Mon Mar 18 11:50:39 2019 +0100
@@ -253,12 +253,6 @@
 void ZPageAllocator::destroy_page(ZPage* page) {
   assert(page->is_detached(), "Invalid page state");
 
-  // Free virtual memory
-  {
-    ZLocker<ZLock> locker(&_lock);
-    _virtual.free(page->virtual_memory());
-  }
-
   delete page;
 }
 
@@ -453,6 +447,9 @@
 void ZPageAllocator::detach_memory(const ZVirtualMemory& vmem, ZPhysicalMemory& pmem) {
   const uintptr_t addr = vmem.start();
 
+  // Free virtual memory
+  _virtual.free(vmem);
+
   // Unmap physical memory
   _physical.unmap(pmem, addr);