Add mi_heap_page_utilization function

This commit is contained in:
githubzilla 2024-05-11 10:10:21 +00:00
parent 89dc53eca9
commit f4181f8d69

View file

@ -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!
// ------------------------------------------------------