Is it possible to set up an arena with jemalloc that only allocates pages from a reserved 2^32 byte area of virtual memory
void* arena_start =
mmap(nullptr, 1ull<<32,
PROT_NONE,
MAP_PRIVATE | MAP_ANONYMOUS,
-1, 0);
so that any pointer allocated from the arena with mallocx
using the MALLOCX_ARENA
option for the arena can be represented as a 32-bit index from arena_start
.
The motivation for this is pointer compression for more space-efficient data structures. (See the paper Tranparent Pointer Compression for Linked DataStructures for background on similar use cases.)
The comments from this thread on arenas make me think this type of customization may be supported.