MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / _mi_heap_collect_retired

Function _mi_heap_collect_retired

3rd/mimalloc-2.0.9/src/page.c:461–486  ·  view source on GitHub ↗

free retired pages: we don't need to look at the entire queues since we only retire pages that are at the head position in a queue.

Source from the content-addressed store, hash-verified

459// free retired pages: we don't need to look at the entire queues
460// since we only retire pages that are at the head position in a queue.
461void _mi_heap_collect_retired(mi_heap_t* heap, bool force) {
462 size_t min = MI_BIN_FULL;
463 size_t max = 0;
464 for(size_t bin = heap->page_retired_min; bin <= heap->page_retired_max; bin++) {
465 mi_page_queue_t* pq = &heap->pages[bin];
466 mi_page_t* page = pq->first;
467 if (page != NULL && page->retire_expire != 0) {
468 if (mi_page_all_free(page)) {
469 page->retire_expire--;
470 if (force || page->retire_expire == 0) {
471 _mi_page_free(pq->first, pq, force);
472 }
473 else {
474 // keep retired, update min/max
475 if (bin < min) min = bin;
476 if (bin > max) max = bin;
477 }
478 }
479 else {
480 page->retire_expire = 0;
481 }
482 }
483 }
484 heap->page_retired_min = min;
485 heap->page_retired_max = max;
486}
487
488
489/* -----------------------------------------------------------

Callers 2

mi_heap_collect_exFunction · 0.85

Calls 2

mi_page_all_freeFunction · 0.85
_mi_page_freeFunction · 0.85

Tested by

no test coverage detected