RFR: 8371637: allocateNativeInternal sometimes return incorrectly aligned memory

Maurizio Cimadamore mcimadamore at openjdk.org
Wed Nov 12 11:30:06 UTC 2025


On Wed, 12 Nov 2025 11:19:51 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> Then, we have three cases:
> 
>     * if the requested alignment `A` is `A <= MIN_ALIGN`, we can just allocate and don't adjust for alignment
> 
>     * if the requested alignment `A` is `MIN_ALIGN < A <= MAX_ALIGN` and the requested size is a multiple of the alignment, also just allocate and don't adjust for alignment
> 
>     * otherwise, allocate a bigger segment and manually align the result

If we can't establish a min alignment, we could at least have some way to determine the max alignment (I'd say probably 16 is a good number because of system ABI?), and then just use two rules:

 * if the requested alignment `A` is `A <= MAX_ALIGN` **and** the requested size is a multiple of the alignment, also just allocate and don't adjust for alignment
 * otherwise, allocate a bigger segment and manually align the result
 
 This should still deliver the kind of compaction we were aiming for with the optimization, but hopefully get there in a more portable way?

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

PR Comment: https://git.openjdk.org/jdk/pull/28235#issuecomment-3521457435


More information about the core-libs-dev mailing list