From c413f61479462b1dfbd774c84ca245dd7d16f1af Mon Sep 17 00:00:00 2001 From: Max Bachmann Date: Wed, 28 Aug 2024 21:57:09 +0200 Subject: [PATCH] fix commited stat _mi_os_free reduces the stat by the full size. So we have to increase it by the uncommited sections beforehand. --- src/arena.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/arena.c b/src/arena.c index 3bb8f502..98579e3e 100644 --- a/src/arena.c +++ b/src/arena.c @@ -632,9 +632,9 @@ void _mi_arena_free(void* p, size_t size, size_t committed_size, mi_memid_t memi if (mi_memkind_is_os(memid.memkind)) { // was a direct OS allocation, pass through - if (!all_committed && committed_size > 0) { - // if partially committed, adjust the committed stats (as `_mi_os_free` will increase decommit by the full size) - _mi_stat_decrease(&_mi_stats_main.committed, committed_size); + if (!all_committed) { + // if partially committed, adjust the committed stats (as `_mi_os_free` reduce the stat by the full size) + _mi_stat_increase(&_mi_stats_main.committed, size - committed_size); } _mi_os_free(p, size, memid, stats); }