round huge page sizes into 12.5% increments (issue
@@ -727,7 +727,10 @@ void mi_register_deferred_free(mi_deferred_free_fun* fn) mi_attr_noexcept {
// just that page, we always treat them as abandoned and any thread
// that frees the block can free the whole page and segment directly.
static mi_page_t* mi_huge_page_alloc(mi_heap_t* heap, size_t size) {
- size_t block_size = _mi_wsize_from_size(size) * sizeof(uintptr_t);
+ size_t align_size = _mi_os_page_size();
+ if (align_size < (size / 8)) align_size = _mi_align_up(size / 8, align_size);
+ if (align_size > MI_SEGMENT_SIZE) align_size = MI_SEGMENT_SIZE;
+ size_t block_size = _mi_align_up(size, align_size);
mi_assert_internal(_mi_bin(block_size) == MI_BIN_HUGE);
mi_page_t* page = mi_page_fresh_alloc(heap,NULL,block_size);
if (page != NULL) {
