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 <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2025-06-04 15:25:51 +02:00
parent fca69d200b
commit 5a05d17cd1

View File

@@ -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)