All in-use monitors maintain a strong reference to their associated object and so will keep it live, even if the monitor reference is the only reference to that object. With asynchronous monitor deflation this can cause a surprise when code uses System.gc() to reclaim memory, but because monitors have not yet been deflated the memory is not actually reclaimed. Prior to JDK-8246477 there was a special hook in JVM_GC to trigger safepoint based deflation before the actual GC. That safepoint-based mechanism has been removed but was replaced with ObjectSynchronizer::request_deflate_idle_monitors(). We should call that in JVM_GC, and in all equivalent APIs (e.g. WhiteBox WB_FullGC).
- relates to
-
JDK-8246477 add whitebox support for deflating idle monitors
- Resolved