--- old/src/hotspot/share/runtime/serviceThread.cpp 2019-05-02 15:05:24.434391044 -0400 +++ new/src/hotspot/share/runtime/serviceThread.cpp 2019-05-02 15:05:23.942391061 -0400 @@ -126,6 +126,7 @@ bool protection_domain_table_work = false; bool oopstorage_work = false; bool oopstorages_cleanup[oopstorage_count] = {}; // Zero (false) initialize. + bool deflate_idle_monitors = false; JvmtiDeferredEvent jvmti_event; { // Need state transition ThreadBlockInVM so that this thread @@ -153,9 +154,9 @@ (protection_domain_table_work = SystemDictionary::pd_cache_table()->has_work()) | (oopstorage_work = needs_oopstorage_cleanup(oopstorages, oopstorages_cleanup, - oopstorage_count))) - - == 0) { + oopstorage_count)) | + (deflate_idle_monitors = ObjectSynchronizer::gOmShouldDeflateIdleMonitors()) + ) == 0) { // Wait until notified that there is some work to do. ml.wait(Mutex::_no_safepoint_check_flag); } @@ -200,6 +201,13 @@ if (oopstorage_work) { cleanup_oopstorages(oopstorages, oopstorages_cleanup, oopstorage_count); } + + if (deflate_idle_monitors) { + // Deflate any global idle monitors. + // deflate_per_thread_idle_monitors_using_JT() is called by + // each JavaThread from ObjectSynchronizer::omAlloc() as needed. + ObjectSynchronizer::deflate_global_idle_monitors_using_JT(); + } } }