mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-06 19:38:41 +03:00
fix rounding issue with huge size allocations
This commit is contained in:
parent
d862e57955
commit
1e1a12bf3c
3 changed files with 12 additions and 14 deletions
|
@ -706,9 +706,10 @@ static inline bool mi_page_is_huge(const mi_page_t* page) {
|
|||
(mi_memkind_is_os(page->memid.memkind) && page->memid.mem.os.base < (void*)page));
|
||||
}
|
||||
|
||||
|
||||
static inline mi_page_queue_t* mi_page_queue(const mi_heap_t* heap, size_t size) {
|
||||
return &((mi_heap_t*)heap)->pages[_mi_bin(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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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-MI_PAGE_INFO_SIZE)/4) // < 512 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_WSIZE (MI_LARGE_MAX_OBJ_SIZE/MI_SIZE_SIZE)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue