mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-08 00:09:31 +03:00
small fixes
This commit is contained in:
parent
8339cefdeb
commit
7ae726bb39
3 changed files with 10 additions and 5 deletions
|
@ -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 <https://sourceware.org/ml/libc-announce/2019/msg00001.html>)
|
// We never allocate more than PTRDIFF_MAX (see also <https://sourceware.org/ml/libc-announce/2019/msg00001.html>)
|
||||||
#define MI_MAX_ALLOC_SIZE PTRDIFF_MAX
|
#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)
|
// Minimal commit for a page on-demand commit (should be >= OS page size)
|
||||||
#define MI_PAGE_MIN_COMMIT_SIZE MI_ARENA_SLICE_SIZE
|
#define MI_PAGE_MIN_COMMIT_SIZE MI_ARENA_SLICE_SIZE // (4*MI_KiB)
|
||||||
|
|
||||||
// ------------------------------------------------------
|
// ------------------------------------------------------
|
||||||
// Arena's are large reserved areas of memory allocated from
|
// Arena's are large reserved areas of memory allocated from
|
||||||
|
|
|
@ -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
|
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(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(page->memid.mem.arena.slice_count >= total_slices);
|
||||||
mi_assert_internal(total_slices > 0);
|
|
||||||
if (total_slices > 0) {
|
if (total_slices > 0) {
|
||||||
mi_bitmap_setN(arena->slices_committed, page->memid.mem.arena.slice_index, total_slices, NULL);
|
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 {
|
else {
|
||||||
mi_assert_internal(mi_bitmap_is_setN(arena->slices_committed, page->memid.mem.arena.slice_index, page->memid.mem.arena.slice_count));
|
mi_assert_internal(mi_bitmap_is_setN(arena->slices_committed, page->memid.mem.arena.slice_index, page->memid.mem.arena.slice_count));
|
||||||
|
@ -1308,7 +1313,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) {
|
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 committed_size = mi_page_committed(page);
|
||||||
const size_t used_size = page->used * mi_page_block_size(page);
|
const size_t used_size = page->used * mi_page_block_size(page);
|
||||||
return (int)(used_size * 100 / committed_size);
|
return (int)(used_size * 100 / committed_size);
|
||||||
|
|
|
@ -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.
|
// Define our own limited `fprintf` that avoids memory allocation.
|
||||||
// We do this using `_mi_vsnprintf` with a limited buffer.
|
// 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 ) {
|
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 (fmt==NULL) return;
|
||||||
if (!mi_recurse_enter()) return;
|
if (!mi_recurse_enter()) return;
|
||||||
_mi_vsnprintf(buf, sizeof(buf)-1, fmt, args);
|
_mi_vsnprintf(buf, sizeof(buf)-1, fmt, args);
|
||||||
|
|
Loading…
Add table
Reference in a new issue