mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-18 21:19:31 +03:00
Add mi_heap_page_utilization function
This commit is contained in:
parent
89dc53eca9
commit
f4181f8d69
1 changed files with 0 additions and 18 deletions
18
src/alloc.c
18
src/alloc.c
|
@ -1064,24 +1064,6 @@ float mi_heap_page_utilization(mi_heap_t* heap, void* p) mi_attr_noexcept {
|
|||
return 1.0;
|
||||
}
|
||||
|
||||
bool mi_heap_page_is_underutilized(mi_heap_t* heap, void* p, float ratio) mi_attr_noexcept {
|
||||
mi_page_t* page = _mi_ptr_page(p); // get the page that this belongs to
|
||||
|
||||
mi_heap_t* page_heap = (mi_heap_t*)(mi_atomic_load_acquire(&(page)->xheap));
|
||||
|
||||
// the heap id matches and it is not a full page
|
||||
if (mi_likely(page_heap == heap && page->flags.x.in_full == 0)) {
|
||||
// first in the list, meaning it's the head of page queue, thus being used for malloc
|
||||
if (page->prev == NULL)
|
||||
return false;
|
||||
|
||||
// this page belong to this heap and is not first in the page queue. Lets check its
|
||||
// utilization.
|
||||
return page->used <= (unsigned)(page->capacity * ratio);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------
|
||||
// ensure explicit external inline definitions are emitted!
|
||||
// ------------------------------------------------------
|
||||
|
|
Loading…
Add table
Reference in a new issue