dlmalloc_inspect_all

Function dlmalloc_inspect_all 

Source
pub unsafe extern "C" fn dlmalloc_inspect_all(
    handler: DLInspectHandler,
    arg: *mut c_void,
)
Expand description

malloc_inspect_all(void(*handler)(void *start,void *end,size_t used_bytes,void* callback_arg),void* arg);

Traverses the heap and calls the given handler for each managed region, skipping all bytes that are (or may be) used for bookkeeping purposes. Traversal does not include include chunks that have been directly memory mapped. Each reported region begins at the start address, and continues up to but not including the end address. The first used_bytes of the region contain allocated data. If used_bytes is zero, the region is unallocated. The handler is invoked with the given callback argument. If locks are defined, they are held during the entire traversal. It is a bad idea to invoke other malloc functions from within the handler.

For example, to count the number of in-use chunks with size greater than 1000, you could write:

static int count = 0;
void count_chunks(void*  start, void* end, size_t used, void* arg)
{
    if (used >= 1000) ++count;
}

then:

malloc_inspect_all(count_chunks, NULL);

malloc_inspect_all is compiled only if MALLOC_INSPECT_ALL is defined.