diff --git a/include/mimalloc/types.h b/include/mimalloc/types.h index 1e33b501..48436724 100644 --- a/include/mimalloc/types.h +++ b/include/mimalloc/types.h @@ -139,8 +139,8 @@ terms of the MIT license. A copy of the license can be found in the file // We never allocate more than PTRDIFF_MAX (see also ) #define MI_MAX_ALLOC_SIZE PTRDIFF_MAX -// Minimal commit for a page on-demand commit (should be >= OS page size, and >= MI_ARENA_SLICE_SIZE for correct stats) -#define MI_PAGE_MIN_COMMIT_SIZE MI_ARENA_SLICE_SIZE +// Minimal commit for a page on-demand commit (should be >= OS page size) +#define MI_PAGE_MIN_COMMIT_SIZE MI_ARENA_SLICE_SIZE // (4*MI_KiB) // ------------------------------------------------------ // Arena's are large reserved areas of memory allocated from diff --git a/src/arena.c b/src/arena.c index b0fa81b9..91c3189c 100644 --- a/src/arena.c +++ b/src/arena.c @@ -832,10 +832,15 @@ 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); } + // any left over? + const size_t extra = page->slice_committed % MI_ARENA_SLICE_SIZE; + if (extra > 0) { + // pretend it was decommitted already + mi_os_stat_decrease(committed, extra); + } } else { mi_assert_internal(mi_bitmap_is_setN(arena->slices_committed, page->memid.mem.arena.slice_index, page->memid.mem.arena.slice_count)); @@ -1314,7 +1319,7 @@ static void mi_debug_color(char* buf, size_t* k, mi_ansi_color_t color) { } static int mi_page_commit_usage(mi_page_t* page) { - if (mi_page_size(page) <= MI_PAGE_MIN_COMMIT_SIZE) return 100; + // if (mi_page_size(page) <= MI_PAGE_MIN_COMMIT_SIZE) return 100; const size_t committed_size = mi_page_committed(page); const size_t used_size = page->used * mi_page_block_size(page); return (int)(used_size * 100 / committed_size); diff --git a/src/options.c b/src/options.c index 9925ac00..efe7ae1e 100644 --- a/src/options.c +++ b/src/options.c @@ -430,7 +430,7 @@ void _mi_fputs(mi_output_fun* out, void* arg, const char* prefix, const char* me // Define our own limited `fprintf` that avoids memory allocation. // We do this using `_mi_vsnprintf` with a limited buffer. static void mi_vfprintf( mi_output_fun* out, void* arg, const char* prefix, const char* fmt, va_list args ) { - char buf[768]; + char buf[992]; if (fmt==NULL) return; if (!mi_recurse_enter()) return; _mi_vsnprintf(buf, sizeof(buf)-1, fmt, args);