#1218·mimalloc

Are pre-mmaped arenas only used when allocating with a heap?

Author: ericr-ehCreated Feb 3, 2026Updated Sep 16, 2026

This might be kind of hard to phrase but here goes..

I'm in a situation (on Linux) where I have to pre-map a HUGE amount of memory per NUMA node. I want that memory to then be used (for now) by malloc and free and I do NOT want mimalloc to attempt to mmap more memory later.

I want these arenas to be significantly bigger than 16GB but that doesn't seem to be an option for now.

To accomplish this, I am:

mi_option_set(mi_option_disallow_os_alloc, 1);

....

mmap(...); // no more than 16GB

            if (!mi_manage_os_memory_ex(
                base,
                size,
                true, /* is_committed */
                true, /* is_large */
                true, /* is_zero (mmap zeroes memory) */
                i, /* numa node */
                false /* exclusive */,
                &pool_node_info[i].arena_ids[j])) { // NOTE: I am NOT using these arena_id's for now
                goto fail;
            }

I am later printing the address of the first and last arena per node. The output is:

bash
node 0 virt 0x26c54e600000
node 0 virt 0x26c579c00000
node 1 virt 0x6b88cb600000
node 1 virt 0x6b88f6c00000

But later when trying to do something with the results of posix_memalign, I get the value 0x7fe616141000, which is clearly outside of the above mmap'ed range.

This leads to two questions:

  1. Am I misunderstanding the mi_option_disallow_os_alloc option? If the arenas are full, shouldn't I get back a NULL?
  2. Why am I not getting something from my mapped arenas? I know I'm not out of memory yet; this is happening early on startup.

Or to put this another way, what should I be doing in order to ensure that mmap is ONLY called at startup and if the arenas fill up I only get NULL back? I thought I had a good handle on the API functions I need but now I'm not so sure.

Thanks!

(EDIT: I'm using version 3.2.7)