memory overhead for allocation a lot of aligned blocks

Vasily Galkin galkin-vv at
Sun Feb 15 22:58:06 PST 2015

I'm trying to implement a technique that would allow to store array limits and specific array position in a single pointer, calculating array limits from pointer alignment.
So I want to allocate arrays of 2**N bytes at 2**N boundary.
The idea is quite genereic so N's value may vary from 8 to huge values like 34 (for 64-bit system).

Analyzing source of glibc allocator for this case I found that for aligned_alloc of 2**N block on 2**N boundary it may introduce worse case 2 times overhead by trying to allocate size+align block, finding aligned address in it and freeing unused part.
jemalloc is more complex so I decided to ask about it.

What is jemalloc worst case overhead for allocating 2**N bytes at 2**N boundary?
I think for jemalloc-huge objects "no overhead" can be achived depends via mmap with fixed aligned adress. Does jemalloc do it such way?
For jemalloc-small and jemalloc-large allocations: does typical 2**N allocs are always aligned to 2**N boundaries or this requirement will change the way how jemalloc handle this allocations?


More information about the jemalloc-discuss mailing list