| 1715 | } |
| 1716 | |
| 1717 | void |
| 1718 | rpmalloc_thread_statistics(rpmalloc_thread_statistics_t* stats) { |
| 1719 | memset(stats, 0, sizeof(rpmalloc_thread_statistics_t)); |
| 1720 | heap_t* heap = _memory_thread_heap; |
| 1721 | #if ENABLE_STATISTICS |
| 1722 | stats->allocated = heap->allocated; |
| 1723 | stats->requested = heap->requested; |
| 1724 | #endif |
| 1725 | void* p = atomic_load_ptr(&heap->defer_deallocate); |
| 1726 | while (p) { |
| 1727 | void* next = *(void**)p; |
| 1728 | span_t* span = (void*)((uintptr_t)p & SPAN_MASK); |
| 1729 | stats->deferred += _memory_size_class[span->size_class].size; |
| 1730 | p = next; |
| 1731 | } |
| 1732 | |
| 1733 | for (size_t isize = 0; isize < SIZE_CLASS_COUNT; ++isize) { |
| 1734 | if (heap->active_block[isize].free_count) |
| 1735 | stats->active += heap->active_block[isize].free_count * _memory_size_class[heap->active_span[isize]->size_class].size; |
| 1736 | |
| 1737 | span_t* cache = heap->size_cache[isize]; |
| 1738 | while (cache) { |
| 1739 | stats->sizecache = cache->data.block.free_count * _memory_size_class[cache->size_class].size; |
| 1740 | cache = cache->next_span; |
| 1741 | } |
| 1742 | } |
| 1743 | |
| 1744 | for (size_t isize = 0; isize < SPAN_CLASS_COUNT; ++isize) { |
| 1745 | if (heap->span_cache[isize]) |
| 1746 | stats->spancache = (size_t)heap->span_cache[isize]->data.list_size * (isize + 1) * SPAN_CLASS_GRANULARITY * PAGE_SIZE; |
| 1747 | } |
| 1748 | } |
| 1749 | |
| 1750 | void |
| 1751 | rpmalloc_global_statistics(rpmalloc_global_statistics_t* stats) { |
nothing calls this directly
no test coverage detected