#659·mimalloc

Request to finish a TODO in code

Author: santagadaCreated Dec 7, 2022Updated Sep 24, 2026
Labelsstale

Hi,

First thanks for the amazing work on mimalloc. I have a problem, we have a quite big workload, a server with 4TB of physical memory that we use by allocating millions of small malloc regions. We have a prune thread that frees objects in a LRU fashion. As we allocate in ~ 200 threads and free in a single one I notices I needed to call mi_collect(true) to force the prune to actually "free" the memory as most/all of it would have come from other threads heaps. That somewhat works, but the memory is not actually freed back to the server, so I would like to request if this todo in segment-cache.c is being worked on by someone, or could:

      // decommit committed parts
      // TODO: instead of decommit, we could also free to the OS?
      mi_commit_mask_decommit(&slot->commit_mask, slot->p, MI_SEGMENT_SIZE, tld->stats);
      mi_commit_mask_create_empty(&slot->decommit_mask);

We are in plans to moving all of this to be done by some form of garbage collector as we have no particular love for the object addresses and it would be fine to move and compact objects, but not for the short/middle term so having this feature can allow us to move this process from jemalloc to mimalloc.

ps: jemalloc also seems to use less committed memory, which on windows server is kinda important as windows needs a pagefile to let you overcommit memory (very silly in my view, but hasn't changed in the past 15 years so I think it won't change soon).