-
Notifications
You must be signed in to change notification settings - Fork 995
Open
Description
I am trying to use mimalloc in memory constrained environments, so I want to use a preallocated arena.
It is similar to #1115 but it happens with mimaloc v2 (from main), and for larger allocations (~60MiB or more).
Also, it seems to ignore the disallow_os_alloc
option, and tries to allocate memory from the OS before failing to allocate.
Here's a small reproducer
#include <stdio.h>
#include <mimalloc.h>
char memory[256 * 1024 * 1024] = {0};
int main(void) {
mi_option_set_enabled(mi_option_disallow_os_alloc, true);
mi_option_set_enabled(mi_option_verbose, true);
mi_manage_os_memory(
memory,
sizeof(memory),
1 /* committed */,
0 /* large */,
0 /* zero */,
-1 /* numa_node */
);
void * ptr = mi_malloc(64 * 1024 * 1024);
fprintf(stderr, "ptr = %p\n", ptr);
mi_option_set_enabled(mi_option_verbose, false);
return ptr ? 0 : 1;
}
This produces the following output
mimalloc: using 1 numa regions
mimalloc: reserved 1048576 KiB memory
mimalloc: reserved 1048576 KiB memory
mimalloc: error: unable to allocate memory (67108864 bytes)
ptr = (nil)
While I would expect it to produce something like
mimalloc: using 1 numa regions
ptr = 0x55e8ee010000
andreiltd
Metadata
Metadata
Assignees
Labels
No labels