RFR: 8365165: Zap C-heap memory at delete/free
Aleksey Shipilev
shade at openjdk.org
Fri Aug 15 15:07:09 UTC 2025
On Fri, 15 Aug 2025 14:54:12 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
>>> Zap on malloc would also be useful.
>>
>> I don't understand. `ZapCHeap`, as implement in current PR, zaps on malloc as well. Well, actually, it just wraps the already existing zapping code with flag guards. I used to call the flag `ZapFreeCHeap`, but then realized we do malloc/realloc side already, so it just claimed those to be a part of the same zapping feature.
>
> Okay, I see. So it's the other way around, we zap newly allocated memory, but not free memory. I thought you were doing that, according to your comment:
>
>> When NMT is enabled (which it is for debug builds), we can also do this for frees, as NMT tells us the size of the free-ed block.
The PR does *all three*, take a look? Current code already zaps on malloc/realloc path, those paths are now under new `ZapCHeap` flag. New code zaps on free path, and it is also under new `ZapCHeap` flag. So in the end, `ZapCHeap` covers malloc/realloc/free, and thus it has a proper name.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26775#discussion_r2279156982
More information about the hotspot-runtime-dev
mailing list