RFR: 8353264: ZGC: Windows heap unreserving is broken

Thomas Stuefe stuefe at openjdk.org
Wed Apr 2 13:30:51 UTC 2025


On Wed, 2 Apr 2025 11:35:36 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:

> During the development of [JDK-8350441](https://bugs.openjdk.org/browse/JDK-8350441) we found that the functionality to release reserved memory for the heap is broken. The current implementation passes in the size of the reserved memory area, but according to the documentation the call should be done with `0` as the dwSize argument:
> 
> If the dwFreeType parameter is MEM_RELEASE, dwSize must be 0 (zero)
> 
> 
> Generational ZGC isn't affected by this because we never release any reserved memory for the heap. However, the changes in JDK-8350441 is going to change that and we will start to release memory in certain corner-cases.
> 
> In Single-gen ZGC, which exists in older releases, we have paths that do release memory for "views" into the heap. This only happens if something blocks the memory areas were we want to set up our "views" of the heap. We should probably backport this fix to the affected releases.
> 
> I've added a unit test that provokes the problem and I have run this fix together with the changes for JDK-8350441.

Okay.

Curious, was this a day zero problem? 

Incidentally, I remember that we had a problem with NUMA on windows where we only released the first NUMA stripe, leaving the other stripes around for future commits to trip over. But ZGC is probably not affected by that, since it does not use os::reserve/release_memory, right?

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

Marked as reviewed by stuefe (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/24377#pullrequestreview-2736284463


More information about the hotspot-gc-dev mailing list