Skip to content
HeapAllocatorPageCount

HeapAllocatorPageCount

Description

Live S/M/L user-page count. The hash table’s occupancy: how many HeapPage descriptors currently track an OS page handed out by this allocator. XL allocations are counted by HeapAllocatorXlCount separately. Useful for sizing decisions and for tests that need to observe grow / reclaim behaviour.

Usage example (Cross-references)

Usage examples (Cross-references)
        // pages_count must be > one batch worth of descriptors -> a second
        // mmap-grow definitely happened.
        ok = ok && (HeapAllocatorPageCount(&heap) > HEAP_PAGES_PER_OS_PAGE);
    
        for (u32 i = 0; i < N; i++) {
        // more if HEAP_PAGES_PER_OS_PAGE > 1 since each grow creates that
        // many siblings).
        ok = ok && (HeapAllocatorPageCount(&heap) >= 8u);
    
        for (u32 i = 0; i < 8; i++) {
        // confirming the two heaps don't share their bookkeeping backing is
        // the whole point of this test.
        bool ok = (a != NULL) && (b != NULL) && (a != b) && (h1.pages != h2.pages) && (HeapAllocatorPageCount(&h1) > 0) &&
                  (HeapAllocatorPageCount(&h2) > 0);
        // the whole point of this test.
        bool ok = (a != NULL) && (b != NULL) && (a != b) && (h1.pages != h2.pages) && (HeapAllocatorPageCount(&h1) > 0) &&
                  (HeapAllocatorPageCount(&h2) > 0);
    
        AllocatorFree(alloc1, a);
Last updated on