From 27b050796b0b05e70e9f7866cdc6f3390223b06f Mon Sep 17 00:00:00 2001 From: Christian Despres Date: Mon, 22 Jan 2024 18:25:58 +0000 Subject: [PATCH] Ensure ROM class cache shutdown is necessary Signed-off-by: Christian Despres --- runtime/compiler/runtime/JITClientSession.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/runtime/compiler/runtime/JITClientSession.cpp b/runtime/compiler/runtime/JITClientSession.cpp index eeabaf9ecd5..812762c295a 100644 --- a/runtime/compiler/runtime/JITClientSession.cpp +++ b/runtime/compiler/runtime/JITClientSession.cpp @@ -1226,6 +1226,8 @@ ClientSessionHT::purgeOldDataIfNeeded() oldAge = OLD_AGE_UNDER_LOW_MEMORY; //memory is low } } + + bool hadExistingClients = !_clientSessionMap.empty(); // Time for a purge operation. // Scan the entire table and delete old elements that are not in use for (auto iter = _clientSessionMap.begin(); iter != _clientSessionMap.end(); ++iter) @@ -1241,8 +1243,8 @@ ClientSessionHT::purgeOldDataIfNeeded() _clientSessionMap.erase(iter); // delete the mapping from the hashtable } } - // If all the clients were deleted, shut down the shared ROMClass cache - if (_clientSessionMap.empty()) + // If the purge operation was responsible for deleting the last client sessions, shut down the shared ROM class cache as well + if (hadExistingClients && _clientSessionMap.empty()) { if (auto cache = TR::CompilationInfo::get()->getJITServerSharedROMClassCache()) cache->shutdown();