From 75d14141dd014da0d42b3478b2be168a4c2d08e2 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 30 Oct 2023 23:06:37 +0100 Subject: [PATCH 1/2] gh-90815: Define WITH_MIMALLOC macro in PC/pyconfig.h --- PC/pyconfig.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/PC/pyconfig.h b/PC/pyconfig.h index ac20129cd30fcc..e6b368caffe280 100644 --- a/PC/pyconfig.h +++ b/PC/pyconfig.h @@ -511,6 +511,9 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ /* Use Python's own small-block memory-allocator. */ #define WITH_PYMALLOC 1 +/* Define if you want to compile in mimalloc memory allocator. */ +#define WITH_MIMALLOC 1 + /* Define if you want to compile in object freelists optimization */ #define WITH_FREELISTS 1 From 7ff8427978cd75639d0214e6b755b6da87b79f80 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 31 Oct 2023 00:33:05 +0100 Subject: [PATCH 2/2] Fix py_mimalloc_print_stats() --- Objects/obmalloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c index d230bbdad3c4cf..b05273b09126eb 100644 --- a/Objects/obmalloc.c +++ b/Objects/obmalloc.c @@ -2738,7 +2738,8 @@ py_mimalloc_print_stats(FILE *out) MI_LARGE_OBJ_SIZE_MAX); mi_heap_t *heap = mi_heap_get_default(); - struct _alloc_stats stats = {}; + struct _alloc_stats stats; + memset(&stats, 0, sizeof(stats)); mi_heap_visit_blocks(heap, false, &_collect_alloc_stats, &stats); fprintf(out, " Allocated Blocks: %ld\n", stats.allocated_blocks);