diff --git a/test/hotspot/gtest/gc/g1/test_freeRegionList.cpp b/test/hotspot/gtest/gc/g1/test_freeRegionList.cpp index ea8027df2a715..e61ce43fdb618 100644 --- a/test/hotspot/gtest/gc/g1/test_freeRegionList.cpp +++ b/test/hotspot/gtest/gc/g1/test_freeRegionList.cpp @@ -44,7 +44,10 @@ TEST_OTHER_VM(G1FreeRegionList, length) { // Create a fake heap. It does not need to be valid, as the G1HeapRegion constructor // does not access it. - MemRegion heap(nullptr, num_regions_in_test * G1HeapRegion::GrainWords); + const size_t szw = num_regions_in_test * G1HeapRegion::GrainWords; + const size_t sz = szw * BytesPerWord; + char* addr = os::reserve_memory_aligned(sz, G1HeapRegion::GrainBytes, mtTest); + MemRegion heap((HeapWord*)addr, szw); // Allocate a fake BOT because the G1HeapRegion constructor initializes // the BOT. @@ -87,5 +90,6 @@ TEST_OTHER_VM(G1FreeRegionList, length) { bot_storage->uncommit_regions(0, num_regions_in_test); delete bot_storage; + os::release_memory(addr, sz); FREE_C_HEAP_ARRAY(HeapWord, bot_data); }