MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / rpmalloc_thread_statistics

Function rpmalloc_thread_statistics

vm/ByteCodeTranslator/src/rpmalloc.c:1717–1748  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1715}
1716
1717void
1718rpmalloc_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
1750void
1751rpmalloc_global_statistics(rpmalloc_global_statistics_t* stats) {

Callers

nothing calls this directly

Calls 1

atomic_load_ptrFunction · 0.85

Tested by

no test coverage detected