--- old/src/hotspot/share/memory/metaspace.cpp 2018-10-25 11:11:31.513441287 -0700 +++ new/src/hotspot/share/memory/metaspace.cpp 2018-10-25 11:11:31.265431829 -0700 @@ -1083,7 +1083,7 @@ #if INCLUDE_CDS // Verify that we can use shared spaces. Otherwise, turn off CDS. if (UseSharedSpaces && !can_use_cds_with_metaspace_addr(metaspace_rs.base(), cds_base)) { - FileMapInfo::stop_sharing_and_unmap( + MetaspaceShared::stop_sharing_and_unmap( "Could not allocate metaspace at a compatible address"); } #endif --- old/src/hotspot/share/memory/metaspaceShared.cpp 2018-10-25 11:11:32.505479119 -0700 +++ new/src/hotspot/share/memory/metaspaceShared.cpp 2018-10-25 11:11:31.917456694 -0700 @@ -2057,6 +2057,12 @@ return true; } +void MetaspaceShared::stop_sharing_and_unmap(const char* msg) { + FileMapInfo::stop_sharing_and_unmap(msg); + MetaspaceObj::_shared_metaspace_base = NULL; + MetaspaceObj::_shared_metaspace_top = NULL; +} + void MetaspaceShared::report_out_of_space(const char* name, size_t needed_bytes) { // This is highly unlikely to happen on 64-bits because we have reserved a 4GB space. // On 32-bit we reserve only 256MB so you could run out of space with 100,000 classes --- old/src/hotspot/share/memory/metaspaceShared.hpp 2018-10-25 11:11:33.065500475 -0700 +++ new/src/hotspot/share/memory/metaspaceShared.hpp 2018-10-25 11:11:32.817491017 -0700 @@ -119,6 +119,7 @@ } static bool map_shared_spaces(FileMapInfo* mapinfo) NOT_CDS_RETURN_(false); static void initialize_shared_spaces() NOT_CDS_RETURN; + static void stop_sharing_and_unmap(const char* msg) NOT_CDS_RETURN; // Return true if given address is in the shared metaspace regions (i.e., excluding any // mapped shared heap regions.)