fix bug in determination of block size in pre-reserved arena memory

This commit is contained in:
Daan Leijen 2021-10-18 20:39:39 -07:00
parent d6bbc08119
commit bcce4d52bf
2 changed files with 4 additions and 2 deletions

View File

@ -287,7 +287,7 @@ bool mi_manage_os_memory(void* start, size_t size, bool is_committed, bool is_la
is_committed = true;
}
const size_t bcount = mi_block_count_of_size(size);
const size_t bcount = size / MI_ARENA_BLOCK_SIZE;
const size_t fields = _mi_divide_up(bcount, MI_BITMAP_FIELD_BITS);
const size_t bitmaps = (is_committed ? 2 : 3);
const size_t asize = sizeof(mi_arena_t) + (bitmaps*fields*sizeof(mi_bitmap_field_t));

View File

@ -498,7 +498,9 @@ void mi_process_init(void) mi_attr_noexcept {
}
if (mi_option_is_enabled(mi_option_reserve_os_memory)) {
long ksize = mi_option_get(mi_option_reserve_os_memory);
if (ksize > 0) mi_reserve_os_memory((size_t)ksize*KiB, true, true);
if (ksize > 0) {
mi_reserve_os_memory(_mi_divide_up((size_t)ksize*KiB, MI_SEGMENT_SIZE), true, true);
}
}
}