mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-12 22:24:58 +03:00
decommit unused prefix of large aligned blocks
This commit is contained in:
parent
27fc2cf17e
commit
2479d168ad
5 changed files with 63 additions and 28 deletions
|
@ -1265,10 +1265,16 @@ static mi_page_t* mi_segment_huge_page_alloc(size_t size, size_t page_alignment,
|
|||
if (page_alignment > 0) {
|
||||
size_t psize;
|
||||
size_t pre_size;
|
||||
void* p = _mi_segment_page_start(segment, page, 0, &psize, &pre_size);
|
||||
void* aligned_p = (void*)_mi_align_up((uintptr_t)p, page_alignment);
|
||||
mi_assert_internal(page_alignment == 0 || _mi_is_aligned(aligned_p, page_alignment));
|
||||
mi_assert_internal(page_alignment == 0 || psize - ((uint8_t*)aligned_p - (uint8_t*)p) >= size);
|
||||
uint8_t* p = (uint8_t*)_mi_segment_page_start(segment, page, 0, &psize, &pre_size);
|
||||
uint8_t* aligned_p = (uint8_t*)_mi_align_up((uintptr_t)p, page_alignment);
|
||||
mi_assert_internal(_mi_is_aligned(aligned_p, page_alignment));
|
||||
mi_assert_internal(psize - (aligned_p - p) >= size);
|
||||
if (!segment->mem_is_pinned && page->is_committed) {
|
||||
// decommit the part of the page that is unused; this can be quite large (close to MI_SEGMENT_SIZE)
|
||||
uint8_t* decommit_start = p + sizeof(mi_block_t); // for the free list
|
||||
ptrdiff_t decommit_size = aligned_p - decommit_start;
|
||||
_mi_mem_decommit(decommit_start, decommit_size, os_tld);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// for huge pages we initialize the xblock_size as we may
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue