Skip to main content

GC_get_heap_size

Function GC_get_heap_size 

Source
pub unsafe extern "C" fn GC_get_heap_size() -> usize
Expand description

Return the number of bytes in the heap. Excludes collector private data structures; excludes the unmapped memory (returned to the OS). Includes empty blocks and fragmentation loss. Includes some pages that were allocated but never written. This is an unsynchronized getter, so it should be called typically with the allocator lock held, at least in the reader mode, to avoid data race on multiprocessors (the alternative way is to use GC_get_prof_stats or GC_get_heap_usage_safe API calls instead). This getter remains lock-free (unsynchronized) for compatibility reason since some existing clients call it from a GC callback holding the allocator lock. (This API function and the following four ones below were made thread-safe in GC v7.2alpha1 and reverted back in v7.2alpha7 for the reason described.)