RFR: 8366865: G1: Allocation GC Pauses Triggered after JVM has started shutdown

Albert Mingkun Yang ayang at openjdk.org
Wed Sep 10 13:59:57 UTC 2025


On Wed, 10 Sep 2025 09:57:18 GMT, Ivan Walulya <iwalulya at openjdk.org> wrote:

> Please review this patch to skip VM_GC_Collect_Operations  if initiated after the VM shutdown process has begun. We add a _is_shutting_down flag to CollectedHeap, which is set while holding the Heap_lock. This ensures mutual exclusion with VM_GC_Collect_Operations, which also require the Heap_lock.
> 
> Skipping VM_GC_Collect_Operation would otherwise cause allocation requests to fail (resulting in OutOfMemoryError) if requesting daemon threads were allowed to continue, we instead block these threads on a monitor. They remain stalled until they are terminated as part of the VM shutdown sequence.
> 
> Testing: Tier 1-7

The PR title shouldn't have `G1:` prefix, as it changes other GCs as well.

src/hotspot/share/gc/shared/collectedHeap.cpp line 617:

> 615:   // To avoid returning nullptr (which could cause premature OOME), we stall
> 616:   // allocation requests here until the VM shutdown is complete.
> 617:   MonitorLocker ml(VMExit_lock);

I wonder if an always-zero-`Semaphore` works.

src/hotspot/share/gc/shared/gcVMOperations.cpp line 115:

> 113: 
> 114:   // Check invocations
> 115:   if (skip_operation() || Universe::heap()->is_shutting_down()) {

Can the new condition be inlined inside `skip_operation()`?

-------------

PR Review: https://git.openjdk.org/jdk/pull/27190#pullrequestreview-3206275122
PR Review Comment: https://git.openjdk.org/jdk/pull/27190#discussion_r2336838170
PR Review Comment: https://git.openjdk.org/jdk/pull/27190#discussion_r2336842785


More information about the hotspot-gc-dev mailing list