diff --git a/include/mimalloc/internal.h b/include/mimalloc/internal.h index 0e161951..49472bdb 100644 --- a/include/mimalloc/internal.h +++ b/include/mimalloc/internal.h @@ -708,8 +708,8 @@ static inline bool mi_page_is_huge(const mi_page_t* page) { static inline mi_page_queue_t* mi_page_queue(const mi_heap_t* heap, size_t size) { mi_page_queue_t* const pq = &((mi_heap_t*)heap)->pages[_mi_bin(size)]; - if (size <= MI_LARGE_MAX_OBJ_SIZE) { mi_assert_internal(pq->block_size <= MI_LARGE_MAX_OBJ_SIZE); } - return pq; + if (size <= MI_LARGE_MAX_OBJ_SIZE) { mi_assert_internal(pq->block_size <= MI_LARGE_MAX_OBJ_SIZE); } + return pq; } diff --git a/include/mimalloc/types.h b/include/mimalloc/types.h index c2a34743..1e33b501 100644 --- a/include/mimalloc/types.h +++ b/include/mimalloc/types.h @@ -49,11 +49,11 @@ terms of the MIT license. A copy of the license can be found in the file // Define MI_SECURE to enable security mitigations. Level 1 has minimal performance impact, // but protects most metadata with guard pages: // #define MI_SECURE 1 // guard page around metadata -// -// Level 2 has more performance impact but protect well against various buffer overflows +// +// Level 2 has more performance impact but protect well against various buffer overflows // by surrounding all mimalloc pages with guard pages: // #define MI_SECURE 2 // guard page around each mimalloc page (can fragment VMA's with large heaps..) -// +// // The next two levels can have more performance cost: // #define MI_SECURE 3 // randomize allocations, encode free lists (detect corrupted free list (buffer overflow), and invalid pointer free) // #define MI_SECURE 4 // checks for double free. (may be more expensive) @@ -293,7 +293,7 @@ typedef struct mi_page_s { _Atomic(mi_page_flags_t) xflags; // `in_full_queue` and `has_aligned` flags size_t block_size; // size available in each block (always `>0`) - uint8_t* page_start; // start of the blocks + uint8_t* page_start; // start of the blocks mi_heaptag_t heap_tag; // tag of the owning heap, used to separate heaps by object type bool free_is_zero; // `true` if the blocks in the free list are zero initialized // padding @@ -328,7 +328,7 @@ typedef struct mi_page_s { // (Except for large pages since huge objects are allocated in 4MiB chunks) #define MI_SMALL_MAX_OBJ_SIZE ((MI_SMALL_PAGE_SIZE-MI_PAGE_INFO_SIZE)/8) // < 8 KiB #define MI_MEDIUM_MAX_OBJ_SIZE ((MI_MEDIUM_PAGE_SIZE-MI_PAGE_INFO_SIZE)/8) // < 64 KiB -#define MI_LARGE_MAX_OBJ_SIZE (MI_LARGE_PAGE_SIZE/4) // <= 512 KiB // note: this must be a nice power of 2 or we get rounding issues with _mi_bin +#define MI_LARGE_MAX_OBJ_SIZE (MI_LARGE_PAGE_SIZE/4) // <= 512 KiB // note: this must be a nice power of 2 or we get rounding issues with _mi_bin #define MI_LARGE_MAX_OBJ_WSIZE (MI_LARGE_MAX_OBJ_SIZE/MI_SIZE_SIZE) diff --git a/src/arena.c b/src/arena.c index 20ae78ee..b0fa81b9 100644 --- a/src/arena.c +++ b/src/arena.c @@ -213,10 +213,6 @@ static mi_decl_noinline void* mi_arena_try_alloc_at( // now actually commit bool commit_zero = false; if (!_mi_os_commit_ex(p, mi_size_of_slices(slice_count), &commit_zero, mi_size_of_slices(slice_count - already_committed_count))) { - // failed to commit (todo: give warning?) - if (already_committed_count > 0) { - mi_subproc_stat_increase(arena->subproc, committed, mi_size_of_slices(already_committed_count)); - } memid->initially_committed = false; } else { @@ -250,7 +246,15 @@ static mi_decl_noinline void* mi_arena_try_alloc_at( } else { // no need to commit, but check if already fully committed + // commit requested, but the range may not be committed as a whole: ensure it is committed now memid->initially_committed = mi_bitmap_is_setN(arena->slices_committed, slice_index, slice_count); + if (!memid->initially_committed) { + // partly committed.. adjust stats + size_t already_committed_count = 0; + mi_bitmap_setN(arena->slices_committed, slice_index, slice_count, &already_committed_count); + mi_bitmap_clearN(arena->slices_committed, slice_index, slice_count); + mi_os_stat_decrease(committed, mi_size_of_slices(already_committed_count)); + } } mi_assert_internal(mi_bbitmap_is_clearN(arena->slices_free, slice_index, slice_count)); @@ -308,7 +312,9 @@ static bool mi_arena_reserve(mi_subproc_t* subproc, size_t req_size, bool allow_ // on an OS with overcommit (Linux) we don't count the commit yet as it is on-demand. Once a slice // is actually allocated for the first time it will be counted. const bool adjust = (overcommit && arena_commit); - if (adjust) { mi_subproc_stat_adjust_decrease( subproc, committed, arena_reserve, true /* on alloc */); } + if (adjust) { + mi_subproc_stat_adjust_decrease( subproc, committed, arena_reserve, true /* on alloc */); + } // and try to reserve the arena int err = mi_reserve_os_memory_ex2(subproc, arena_reserve, arena_commit, allow_large, false /* exclusive? */, arena_id); if (err != 0) { @@ -563,7 +569,6 @@ static mi_page_t* mi_arenas_page_try_find_abandoned(mi_subproc_t* subproc, size_ _mi_page_free_collect(page, false); // update `used` count mi_assert_internal(mi_bbitmap_is_clearN(arena->slices_free, slice_index, slice_count)); mi_assert_internal(page->slice_committed > 0 || mi_bitmap_is_setN(arena->slices_committed, slice_index, slice_count)); - mi_assert_internal(mi_bbitmap_is_clearN(arena->slices_free, slice_index, slice_count)); mi_assert_internal(mi_bitmap_is_setN(arena->slices_dirty, slice_index, slice_count)); mi_assert_internal(_mi_is_aligned(page, MI_PAGE_ALIGN)); mi_assert_internal(_mi_ptr_page(page)==page); @@ -723,7 +728,7 @@ static mi_page_t* mi_arenas_page_regular_alloc(mi_heap_t* heap, size_t slice_cou // 2. find a free block, potentially allocating a new arena const long commit_on_demand = mi_option_get(mi_option_page_commit_on_demand); const bool commit = (slice_count <= mi_slice_count_of_size(MI_PAGE_MIN_COMMIT_SIZE) || // always commit small pages - (commit_on_demand == 2 && _mi_os_has_overcommit()) || (commit_on_demand == 1)); + (commit_on_demand == 2 && _mi_os_has_overcommit()) || (commit_on_demand == 0)); page = mi_arenas_page_alloc_fresh(tld->subproc, slice_count, block_size, 1, req_arena, tld->thread_seq, commit); if (page != NULL) { mi_assert_internal(page->memid.memkind != MI_MEM_ARENA || page->memid.mem.arena.slice_count == slice_count); @@ -827,6 +832,7 @@ void _mi_arenas_page_free(mi_page_t* page) { const size_t total_slices = page->slice_committed / MI_ARENA_SLICE_SIZE; // conservative //mi_assert_internal(mi_bitmap_is_clearN(arena->slices_committed, page->memid.mem.arena.slice_index, total_slices)); mi_assert_internal(page->memid.mem.arena.slice_count >= total_slices); + mi_assert_internal(total_slices > 0); if (total_slices > 0) { mi_bitmap_setN(arena->slices_committed, page->memid.mem.arena.slice_index, total_slices, NULL); } @@ -1168,9 +1174,9 @@ static bool mi_manage_os_memory_ex2(mi_subproc_t* subproc, void* start, size_t s mi_arena_t* arena = (mi_arena_t*)start; - // commit & zero if needed + // commit & zero if needed if (!memid.initially_committed) { - // leave a guard OS page decommitted at the end + // leave a guard OS page decommitted at the end _mi_os_commit(arena, mi_size_of_slices(info_slices) - _mi_os_secure_guard_page_size(), NULL); } else { @@ -1187,7 +1193,7 @@ static bool mi_manage_os_memory_ex2(mi_subproc_t* subproc, void* start, size_t s arena->is_exclusive = exclusive; arena->slice_count = slice_count; arena->info_slices = info_slices; - arena->numa_node = numa_node; // TODO: or get the current numa node if -1? (now it allows anyone to allocate on -1) + arena->numa_node = numa_node; // TODO: or get the current numa node if -1? (now it allows anyone to allocate on -1) arena->purge_expire = 0; // mi_lock_init(&arena->abandoned_visit_lock); @@ -1299,7 +1305,7 @@ typedef enum mi_ansi_color_e { } mi_ansi_color_t; static void mi_debug_color(char* buf, size_t* k, mi_ansi_color_t color) { - buf[*k] = '\x1b'; + buf[*k] = '\x1b'; buf[*k+1] = '['; buf[*k+2] = (char)(((int)color / 10) + '0'); buf[*k+3] = (char)(((int)color % 10) + '0'); @@ -1349,7 +1355,7 @@ static size_t mi_debug_show_page_bfield(mi_bfield_t field, char* buf, size_t* k, else if (mi_bitmap_is_setN(arena->slices_committed, slice_index + bit, 1)) { c = '_'; color = MI_GRAY; } else { c = '.'; color = MI_GRAY; } } - if (bit==MI_BFIELD_BITS-1 && bit_of_page > 1) { c = '>'; } + if (bit==MI_BFIELD_BITS-1 && bit_of_page > 1) { c = '>'; } } if (color != prev_color) { mi_debug_color(buf, k, color); @@ -1434,14 +1440,14 @@ void mi_debug_show_arenas(bool show_pages) mi_attr_noexcept { mi_subproc_t* subproc = _mi_subproc(); size_t max_arenas = mi_arenas_get_count(subproc); //size_t free_total = 0; - size_t slice_total = 0; + //size_t slice_total = 0; //size_t abandoned_total = 0; size_t page_total = 0; for (size_t i = 0; i < max_arenas; i++) { mi_arena_t* arena = mi_atomic_load_ptr_acquire(mi_arena_t, &subproc->arenas[i]); if (arena == NULL) break; mi_assert(arena->subproc == subproc); - slice_total += arena->slice_count; + // slice_total += arena->slice_count; _mi_output_message("arena %zu at %p: %zu slices (%zu MiB)%s, subproc: %p\n", i, arena, arena->slice_count, mi_size_of_slices(arena->slice_count)/MI_MiB, (arena->memid.is_pinned ? ", pinned" : ""), arena->subproc); //if (show_inuse) { // free_total += mi_debug_show_bbitmap("in-use slices", arena->slice_count, arena->slices_free, true, NULL); @@ -1540,7 +1546,7 @@ int mi_reserve_huge_os_pages(size_t pages, double max_secs, size_t* pages_reserv static long mi_arena_purge_delay(void) { // <0 = no purging allowed, 0=immediate purging, >0=milli-second delay - return (mi_option_get(mi_option_purge_delay) * mi_option_get(mi_option_arena_purge_mult)); + return (mi_option_get(mi_option_purge_delay) * mi_option_get(mi_option_arena_purge_mult)); } // reset or decommit in an arena and update the commit bitmap @@ -1567,7 +1573,7 @@ static bool mi_arena_purge(mi_arena_t* arena, size_t slice_index, size_t slice_c else if (!all_committed) { // we cannot assume any of these are committed any longer (even with reset since we did setN and may have marked uncommitted slices as committed) mi_bitmap_clearN(arena->slices_committed, slice_index, slice_count); - // we adjust the commit count as parts will be re-committed + // we adjust the commit count as parts will be re-committed // mi_os_stat_decrease(committed, mi_size_of_slices(already_committed)); } @@ -1656,7 +1662,7 @@ static bool mi_arena_try_purge(mi_arena_t* arena, mi_msecs_t now, bool force) mi_msecs_t expire = mi_atomic_loadi64_relaxed(&arena->purge_expire); if (!force && (expire == 0 || expire > now)) return false; - // reset expire + // reset expire mi_atomic_store_release(&arena->purge_expire, (mi_msecs_t)0); mi_subproc_stat_counter_increase(arena->subproc, arena_purges, 1); @@ -1731,8 +1737,8 @@ static bool abandoned_page_visit(mi_page_t* page, mi_abandoned_page_visit_info_t if (page->heap_tag != vinfo->heap_tag) { return true; } // continue mi_heap_area_t area; _mi_heap_area_init(&area, page); - if (!vinfo->visitor(NULL, &area, NULL, area.block_size, vinfo->arg)) { - return false; + if (!vinfo->visitor(NULL, &area, NULL, area.block_size, vinfo->arg)) { + return false; } if (vinfo->visit_blocks) { return _mi_heap_area_visit_blocks(&area, page, vinfo->visitor, vinfo->arg); @@ -1747,7 +1753,7 @@ static bool abandoned_page_visit_at(size_t slice_index, size_t slice_count, mi_a mi_abandoned_page_visit_info_t* vinfo = (mi_abandoned_page_visit_info_t*)arg; mi_page_t* page = (mi_page_t*)mi_arena_slice_start(arena, slice_index); mi_assert_internal(mi_page_is_abandoned_mapped(page)); - return abandoned_page_visit(page, vinfo); + return abandoned_page_visit(page, vinfo); } // Visit all abandoned pages in this subproc. diff --git a/src/options.c b/src/options.c index 0a9a5f92..9925ac00 100644 --- a/src/options.c +++ b/src/options.c @@ -144,7 +144,7 @@ static mi_option_desc_t options[_mi_option_last] = #else { 1, UNINIT, MI_OPTION(eager_commit_delay) }, // the first N segments per thread are not eagerly committed (but per page in the segment on demand) #endif - { 2500,UNINIT, MI_OPTION_LEGACY(purge_delay,reset_delay) }, // purge delay in milli-seconds + { 0, UNINIT, MI_OPTION_LEGACY(purge_delay,reset_delay) }, // purge delay in milli-seconds { 0, UNINIT, MI_OPTION(use_numa_nodes) }, // 0 = use available numa nodes, otherwise use at most N nodes. { 0, UNINIT, MI_OPTION_LEGACY(disallow_os_alloc,limit_os_alloc) }, // 1 = do not use OS memory for allocation (but only reserved arenas) { 100, UNINIT, MI_OPTION(os_tag) }, // only apple specific for now but might serve more or less related purpose diff --git a/src/os.c b/src/os.c index ef440fcd..65998e88 100644 --- a/src/os.c +++ b/src/os.c @@ -108,7 +108,7 @@ size_t _mi_os_secure_guard_page_size(void) { #endif } -// In secure mode, try to decommit an area and output a warning if this fails. +// In secure mode, try to decommit an area and output a warning if this fails. bool _mi_os_secure_guard_page_set_at(void* addr, bool is_pinned) { if (addr == NULL) return true; #if MI_SECURE > 0 @@ -123,7 +123,7 @@ bool _mi_os_secure_guard_page_set_at(void* addr, bool is_pinned) { #endif } -// In secure mode, try to decommit an area and output a warning if this fails. +// In secure mode, try to decommit an area and output a warning if this fails. bool _mi_os_secure_guard_page_set_before(void* addr, bool is_pinned) { return _mi_os_secure_guard_page_set_at((uint8_t*)addr - _mi_os_secure_guard_page_size(), is_pinned); } @@ -143,22 +143,21 @@ bool _mi_os_secure_guard_page_reset_before(void* addr) { return _mi_os_secure_guard_page_reset_at((uint8_t*)addr - _mi_os_secure_guard_page_size()); } - /* ----------------------------------------------------------- Free memory -------------------------------------------------------------- */ static void mi_os_free_huge_os_pages(void* p, size_t size); -static void mi_os_prim_free(void* addr, size_t size, bool still_committed) { +static void mi_os_prim_free(void* addr, size_t size, size_t commit_size) { mi_assert_internal((size % _mi_os_page_size()) == 0); if (addr == NULL || size == 0) return; // || _mi_os_is_huge_reserved(addr) int err = _mi_prim_free(addr, size); if (err != 0) { _mi_warning_message("unable to free OS memory (error: %d (0x%x), size: 0x%zx bytes, address: %p)\n", err, err, size, addr); } - if (still_committed) { - mi_os_stat_decrease(committed, size); + if (commit_size > 0) { + mi_os_stat_decrease(committed, commit_size); } mi_os_stat_decrease(reserved, size); } @@ -167,13 +166,19 @@ void _mi_os_free_ex(void* addr, size_t size, bool still_committed, mi_memid_t me if (mi_memkind_is_os(memid.memkind)) { size_t csize = memid.mem.os.size; if (csize==0) { _mi_os_good_alloc_size(size); } + size_t commit_size = (still_committed ? csize : 0); void* base = addr; // different base? (due to alignment) if (memid.mem.os.base != base) { mi_assert(memid.mem.os.base <= addr); - // mi_assert((uint8_t*)memid.mem.os.base + memid.mem.os.alignment >= (uint8_t*)addr); base = memid.mem.os.base; - if (memid.mem.os.size==0) { csize += ((uint8_t*)addr - (uint8_t*)memid.mem.os.base); } + const size_t diff = (uint8_t*)addr - (uint8_t*)memid.mem.os.base; + if (memid.mem.os.size==0) { + csize += diff; + } + if (still_committed) { + commit_size -= diff; // the (addr-base) part was already un-committed + } } // free it if (memid.memkind == MI_MEM_OS_HUGE) { @@ -181,7 +186,7 @@ void _mi_os_free_ex(void* addr, size_t size, bool still_committed, mi_memid_t me mi_os_free_huge_os_pages(base, csize); } else { - mi_os_prim_free(base, csize, still_committed); + mi_os_prim_free(base, csize, (still_committed ? commit_size : 0)); } } else { @@ -266,7 +271,7 @@ static void* mi_os_prim_alloc_aligned(size_t size, size_t alignment, bool commit _mi_warning_message("unable to allocate aligned OS memory directly, fall back to over-allocation (size: 0x%zx bytes, address: %p, alignment: 0x%zx, commit: %d)\n", size, p, alignment, commit); } #endif - if (p != NULL) { mi_os_prim_free(p, size, commit); } + if (p != NULL) { mi_os_prim_free(p, size, (commit ? size : 0)); } if (size >= (SIZE_MAX - alignment)) return NULL; // overflow const size_t over_size = size + alignment; @@ -297,8 +302,8 @@ static void* mi_os_prim_alloc_aligned(size_t size, size_t alignment, bool commit size_t mid_size = _mi_align_up(size, _mi_os_page_size()); size_t post_size = over_size - pre_size - mid_size; mi_assert_internal(pre_size < over_size&& post_size < over_size&& mid_size >= size); - if (pre_size > 0) { mi_os_prim_free(p, pre_size, commit); } - if (post_size > 0) { mi_os_prim_free((uint8_t*)aligned_p + mid_size, post_size, commit); } + if (pre_size > 0) { mi_os_prim_free(p, pre_size, (commit ? pre_size : 0)); } + if (post_size > 0) { mi_os_prim_free((uint8_t*)aligned_p + mid_size, post_size, (commit ? post_size : 0)); } // we can return the aligned pointer on `mmap` systems p = aligned_p; *base = aligned_p; // since we freed the pre part, `*base == p`. @@ -454,9 +459,9 @@ bool _mi_os_commit(void* addr, size_t size, bool* is_zero) { return _mi_os_commit_ex(addr, size, is_zero, size); } -static bool mi_os_decommit_ex(void* addr, size_t size, bool* needs_recommit, size_t stats_size) { +static bool mi_os_decommit_ex(void* addr, size_t size, bool* needs_recommit, size_t stat_size) { mi_assert_internal(needs_recommit!=NULL); - mi_os_stat_decrease(committed, stats_size); + mi_os_stat_decrease(committed, stat_size); // page align size_t csize; @@ -505,7 +510,7 @@ bool _mi_os_reset(void* addr, size_t size) { // either resets or decommits memory, returns true if the memory needs // to be recommitted if it is to be re-used later on. -bool _mi_os_purge_ex(void* p, size_t size, bool allow_reset, size_t stats_size) +bool _mi_os_purge_ex(void* p, size_t size, bool allow_reset, size_t stat_size) { if (mi_option_get(mi_option_purge_delay) < 0) return false; // is purging allowed? mi_os_stat_counter_increase(purge_calls, 1); @@ -515,7 +520,7 @@ bool _mi_os_purge_ex(void* p, size_t size, bool allow_reset, size_t stats_size) !_mi_preloading()) // don't decommit during preloading (unsafe) { bool needs_recommit = true; - mi_os_decommit_ex(p, size, &needs_recommit, stats_size); + mi_os_decommit_ex(p, size, &needs_recommit, stat_size); return needs_recommit; } else { @@ -636,7 +641,7 @@ void* _mi_os_alloc_huge_os_pages(size_t pages, int numa_node, mi_msecs_t max_mse // no success, issue a warning and break if (p != NULL) { _mi_warning_message("could not allocate contiguous huge OS page %zu at %p\n", page, addr); - mi_os_prim_free(p, MI_HUGE_OS_PAGE_SIZE, true); + mi_os_prim_free(p, MI_HUGE_OS_PAGE_SIZE, MI_HUGE_OS_PAGE_SIZE); } break; } @@ -682,7 +687,7 @@ static void mi_os_free_huge_os_pages(void* p, size_t size) { if (p==NULL || size==0) return; uint8_t* base = (uint8_t*)p; while (size >= MI_HUGE_OS_PAGE_SIZE) { - mi_os_prim_free(base, MI_HUGE_OS_PAGE_SIZE, true); + mi_os_prim_free(base, MI_HUGE_OS_PAGE_SIZE, MI_HUGE_OS_PAGE_SIZE); size -= MI_HUGE_OS_PAGE_SIZE; base += MI_HUGE_OS_PAGE_SIZE; } diff --git a/src/page-map.c b/src/page-map.c index db14265b..a917175a 100644 --- a/src/page-map.c +++ b/src/page-map.c @@ -160,6 +160,7 @@ mi_decl_nodiscard mi_decl_export bool mi_is_in_heap_region(const void* p) mi_att #else // A 2-level page map +#define MI_PAGE_MAP_SUB_SIZE (MI_PAGE_MAP_SUB_COUNT * sizeof(mi_page_t*)) mi_decl_cache_align mi_page_t*** _mi_page_map; static void* mi_page_map_max_address; @@ -167,6 +168,7 @@ static mi_memid_t mi_page_map_memid; static _Atomic(mi_bfield_t) mi_page_map_commit; +static mi_page_t** mi_page_map_ensure_committed(size_t idx); static mi_page_t** mi_page_map_ensure_at(size_t idx); static inline void mi_page_map_set_range(mi_page_t* page, size_t idx, size_t sub_idx, size_t slice_count); @@ -200,16 +202,17 @@ bool _mi_page_map_init(void) { } mi_atomic_store_release(&mi_page_map_commit, (commit ? ~MI_ZU(0) : MI_ZU(0))); - // commit the first part so NULL pointers get resolved without an access violation - mi_page_map_ensure_at(0); - - // note: for the NULL range we only commit one OS page - // mi_page_map_set_range(NULL, 0, 0, 1); - _mi_page_map[0] = (mi_page_t**)((uint8_t*)_mi_page_map + page_map_size); + // note: for the NULL range we only commit one OS page (in the map and sub) if (!mi_page_map_memid.initially_committed) { - _mi_os_commit(_mi_page_map[0], os_page_size, NULL); + _mi_os_commit(&_mi_page_map[0], os_page_size, NULL); // commit first part of the map + } + _mi_page_map[0] = (mi_page_t**)((uint8_t*)_mi_page_map + page_map_size); // we reserved 2 subs at the end already + if (!mi_page_map_memid.initially_committed) { + _mi_os_commit(_mi_page_map[0], os_page_size, NULL); // only first OS page + } + if (!mi_page_map_memid.initially_zero) { + _mi_page_map[0][0] = NULL; } - _mi_page_map[0][0] = NULL; mi_assert_internal(_mi_ptr_page(NULL)==NULL); return true; diff --git a/test/test-stress.c b/test/test-stress.c index a4b55caf..653c0a1a 100644 --- a/test/test-stress.c +++ b/test/test-stress.c @@ -48,7 +48,7 @@ static int ITER = 20; static int THREADS = 32; static int SCALE = 50; static int ITER = 50; -#elif 1 +#elif 0 static int THREADS = 32; static int SCALE = 25; static int ITER = 50; @@ -82,6 +82,7 @@ static bool main_participates = false; // main thread participates as a #define custom_calloc(n,s) mi_calloc(n,s) #define custom_realloc(p,s) mi_realloc(p,s) #define custom_free(p) mi_free(p) + #ifndef NDEBUG #define xHEAP_WALK // walk the heap objects? #endif