-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
I'm using mimalloc as drop-in malloc replacement. For my usecase I want to preallocate big area of 2M huge-pages and make mimalloc use that area for all allocations unless it's fully used in which case I want to fallback to additional memory (regular mmap).
The preallocated area should be enough for 99.9% of runtime and only in extreme cases (e.g. bugs and leaks) I expect additional mmaps.
I'm setting these environment options:
MIMALLOC_RESERVE_HUGE_OS_PAGES=14
MIMALLOC_PURGE_DELAY=-1
MIMALLOC_VERBOSE=1
MIMALLOC_SHOW_STATS=1
MIMALLOC_SHOW_ERRORS=1
I've also added logging around mmap/munmap calls. I expected not to see any additional calls besides initial 14 calls to mmap with 1 GiB size. However I still see numerous mmap calls with size 64kb at init time.
When I tried to setting disallow_os_alloc=1, I've got ENOMEM early in application init, definitely before 14GB were exhausted. I looks like mimalloc tries to allocate from OS even if there is plenty of free memory in preallocated area.
Am I misunderstanding something?
There's similar recent question #1218, but AFAIU it only applies to arenas larger than 16GB while in my case I have 14GB.