--- old/src/hotspot/share/memory/filemap.cpp 2020-02-14 15:56:28.183568008 +0100 +++ new/src/hotspot/share/memory/filemap.cpp 2020-02-14 15:56:27.971564497 +0100 @@ -1768,12 +1768,14 @@ } if (region_num == 0) { + FREE_C_HEAP_ARRAY(MemRegion, regions); return false; // no archived java heap data } // Check that ranges are within the java heap if (!G1CollectedHeap::heap()->check_archive_addresses(regions, region_num)) { log_info(cds)("UseSharedSpaces: Unable to allocate region, range is not within java heap."); + FREE_C_HEAP_ARRAY(MemRegion, regions); return false; } @@ -1781,6 +1783,7 @@ if (!G1CollectedHeap::heap()->alloc_archive_regions( regions, region_num, is_open_archive)) { log_info(cds)("UseSharedSpaces: Unable to allocate region, java heap range is already in use."); + FREE_C_HEAP_ARRAY(MemRegion, regions); return false; } @@ -1799,6 +1802,7 @@ log_info(cds)("UseSharedSpaces: Unable to map at required address in java heap. " INTPTR_FORMAT ", size = " SIZE_FORMAT " bytes", p2i(addr), regions[i].byte_size()); + FREE_C_HEAP_ARRAY(MemRegion, regions); return false; } @@ -1806,6 +1810,7 @@ // dealloc the regions from java heap dealloc_archive_heap_regions(regions, region_num); log_info(cds)("UseSharedSpaces: mapped heap regions are corrupt"); + FREE_C_HEAP_ARRAY(MemRegion, regions); return false; } }