From 5a05d17cd1db5b07408edbb91a6df520e7dbb68f Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 4 Jun 2025 15:25:51 +0200 Subject: [PATCH] mimalloc: avoid excessive memory retention In commit cfe73e9d (wip: merging from upstream, 2024-12-25), mimalloc introduced a bug where memory is retained excessively. This leads to a problem e.g. when fetching Git for Windows' `main` branch using the i686 variant of Git for Windows because it simply runs out of address space. Fix this as suggested in https://github.com/microsoft/mimalloc/issues/1025#issuecomment-2768863283 Signed-off-by: Johannes Schindelin --- compat/mimalloc/os.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/mimalloc/os.c b/compat/mimalloc/os.c index 2472b8030b..2a3dd09b89 100644 --- a/compat/mimalloc/os.c +++ b/compat/mimalloc/os.c @@ -166,7 +166,7 @@ static void mi_os_prim_free(void* addr, size_t size, size_t commit_size) { void _mi_os_free_ex(void* addr, size_t size, bool still_committed, mi_memid_t memid) { if (mi_memkind_is_os(memid.memkind)) { size_t csize = memid.mem.os.size; - if (csize==0) { _mi_os_good_alloc_size(size); } + if (csize==0) { csize = _mi_os_good_alloc_size(size); } size_t commit_size = (still_committed ? csize : 0); void* base = addr; // different base? (due to alignment)