On 7/23/20 5:24 AM, Florian Weimer wrote:
Ah, 4096 is too small.

For large allocations (above the mmap threshold), what happens in the
example is that the process VMA limit is eventually exhausted, at which
malloc falls back to sbrk, and then the algorithm succeeds.  I don't
think it's a good idea to trigger ENOMEM, it's certainly not
thread-safe.

I'm not sure I see what ENOMEM has to do with it if the algorithm is succeeding.

Anyway, none of this matters since glibc has aligned_alloc already. All that matters is how well native MS-Windows performs since it's the only significant platform that lacks native support for aligned allocation. I don't use MS-Windows so I'm not the best person to comment on it; still, I'd be surprised if there's no way to support common uses of aligned_alloc on MS-Windows, such as the use that prompted this thread.

Reply via email to