8220591: ZGC: Don't delay reclaimation of ZVirtualMemory
Reviewed-by: stefank, eosterlund
--- 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);