RFR: 8366925: Improper std::nothrow new expression in NativeHeapTrimmerThread ctor

Albert Mingkun Yang ayang at openjdk.org
Mon Sep 15 10:24:10 UTC 2025


On Mon, 15 Sep 2025 01:01:17 GMT, Guanqiang Han <ghan at openjdk.org> wrote:

> Please review this Patch.
> 
> **Description:**
> Add null check for _lock in NativeHeapTrimmerThread constructor. If allocation of the lock fails (_lock == nullptr), it indicates an out-of-memory condition. Since even this small allocation failed, it's unlikely that subsequent operations would succeed, so we terminate the JVM immediately.

Why does the init of `_lock` use `std::nothrow`? `PaddedMonitor` is `CHeapObj` -- wouldn't the default `new` operator invoke the exit-on-oom?

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

PR Review: https://git.openjdk.org/jdk/pull/27275#pullrequestreview-3223899152


More information about the hotspot-runtime-dev mailing list