mi-malloc v1.9, v2.2, v3.2
 
Loading...
Searching...
No Matches
Statistics

Print out allocation statistics. More...

Data Structures

struct  mi_stats_t
 Statistics. See include/mimalloc-stats.h for the full definition. More...
 

Macros

#define MI_STAT_VERSION
 Statistics version. Increased on each backward incompatible change.
 
#define mi_stats_t_decl(name)
 Helper to declare a properly initialized mi_stats_t() local variable as name where the size and version fields are properly initialized.
 

Functions

void mi_process_info_print (void)
 Print out all process info.
 
void mi_process_info_print_out (mi_output_fun *out, void *arg)
 Print out all process info.
 
void mi_process_info (size_t *elapsed_msecs, size_t *user_msecs, size_t *system_msecs, size_t *current_rss, size_t *peak_rss, size_t *current_commit, size_t *peak_commit, size_t *page_faults)
 Return process information (time and memory usage).
 
void mi_stats_print (void *out)
 Deprecated.
 
void mi_stats_print_out (mi_output_fun *out, void *arg)
 Print statistics of the current subprocess aggregated over all its heaps.
 
bool mi_stats_get (mi_stats_t *stats)
 Get the statistics for the current subprocess aggregated over all its heaps.
 
char * mi_stats_get_json (size_t buf_size, char *buf)
 Get the statistics for the current subprocess aggregated over all its heaps as JSON.
 
size_t mi_stats_get_bin_size (size_t bin)
 v3: Return the block size for the given bin.
 
bool mi_heap_stats_get (mi_heap_t *heap, mi_stats_t *stats)
 v3: Return statistics for a given heap.
 
char * mi_heap_stats_get_json (mi_heap_t *heap, size_t buf_size, char *buf)
 v3: Get the statistics for a heap as JSON.
 
void mi_heap_stats_print_out (mi_heap_t *heap, mi_output_fun *out, void *arg)
 v3: Show the heap statistics as JSON.
 
void mi_heap_stats_merge_to_subproc (mi_heap_t *heap)
 v3: xplicitly merge the statistics of the current heap with the subprocess.
 
bool mi_subproc_stats_get (mi_subproc_id_t subproc_id, mi_stats_t *stats)
 v3: Get statistics for a given subprocess aggregated over all its heaps.
 
char * mi_subproc_stats_get_json (mi_subproc_id_t subproc_id, size_t buf_size, char *buf)
 v3: Show the subproc statistics aggregated over all its heaps as JSON.
 
void mi_subproc_stats_print_out (mi_subproc_id_t subproc_id, mi_output_fun *out, void *arg)
 v3: Print the subproc statistics aggregated over all its heaps.
 
void mi_subproc_heap_stats_print_out (mi_subproc_id_t subproc_id, mi_output_fun *out, void *arg)
 v3: Print statistics for a given subprocess with each heap separately printed.
 
char * mi_stats_as_json (mi_stats_t *stats, size_t buf_size, char *buf)
 v3: Show the given statistics as JSON.
 
void mi_stats_reset (void)
 v1,v2: Reset statistics.
 
void mi_stats_merge (void)
 v1,v2: Merge thread local statistics with the main statistics and reset.
 

Detailed Description

Print out allocation statistics.


Data Structure Documentation

◆ mi_stats_s

struct mi_stats_s

Statistics. See include/mimalloc-stats.h for the full definition.

Data Fields
size_t size initialize with sizeof(mi_stats_t) (so linking dynamically with a separately compiled mimalloc is safe)
size_t version initialize with `MI_STAT_VERSION (so linking dynamically with a separately compiled mimalloc is safe)

Macro Definition Documentation

◆ MI_STAT_VERSION

#define MI_STAT_VERSION

Statistics version. Increased on each backward incompatible change.

◆ mi_stats_t_decl

#define mi_stats_t_decl ( name)

Helper to declare a properly initialized mi_stats_t() local variable as name where the size and version fields are properly initialized.

For example:

if (mi_stats_get(&stats)) {
...
}
#define mi_stats_t_decl(name)
Helper to declare a properly initialized mi_stats_t() local variable as name where the size and versi...
Definition mimalloc-doc.h:1026
bool mi_stats_get(mi_stats_t *stats)
Get the statistics for the current subprocess aggregated over all its heaps.

Function Documentation

◆ mi_heap_stats_get()

bool mi_heap_stats_get ( mi_heap_t * heap,
mi_stats_t * stats )

v3: Return statistics for a given heap.

Parameters
heapThe heap.
statsPointer to a mi_stats_t() structure (declared as mi_stats_t_decl(name)).
Returns
true if stats is not NULL, and if stats->size and stats->version match the sizeof(mi_stats_t) and MI_STAT_VERSION with the linked mimalloc version.

◆ mi_heap_stats_get_json()

char * mi_heap_stats_get_json ( mi_heap_t * heap,
size_t buf_size,
char * buf )

v3: Get the statistics for a heap as JSON.

Parameters
heapThe heap.
buf_sizeByte size of the buffer buf (or 0 if buf is NULL).
bufThe buffer. Pass NULL to allocate a fresh buffer.
Returns
Pointer to the buffer or NULL on failure. Use mi_free() to free the buffer if the buf parameter was NULL.

◆ mi_heap_stats_merge_to_subproc()

void mi_heap_stats_merge_to_subproc ( mi_heap_t * heap)

v3: xplicitly merge the statistics of the current heap with the subprocess.

Parameters
heapThe heap. After this call, the heap statistics are reset.

◆ mi_heap_stats_print_out()

void mi_heap_stats_print_out ( mi_heap_t * heap,
mi_output_fun * out,
void * arg )

v3: Show the heap statistics as JSON.

Parameters
heapThe heap.
outAn output function or NULL for the default.
argOptional argument passed to out (if not NULL)

◆ mi_process_info()

void mi_process_info ( size_t * elapsed_msecs,
size_t * user_msecs,
size_t * system_msecs,
size_t * current_rss,
size_t * peak_rss,
size_t * current_commit,
size_t * peak_commit,
size_t * page_faults )

Return process information (time and memory usage).

Parameters
elapsed_msecsOptional. Elapsed wall-clock time of the process in milli-seconds.
user_msecsOptional. User time in milli-seconds (as the sum over all threads).
system_msecsOptional. System time in milli-seconds.
current_rssOptional. Current working set size (touched pages).
peak_rssOptional. Peak working set size (touched pages).
current_commitOptional. Current committed memory (backed by the page file).
peak_commitOptional. Peak committed memory (backed by the page file).
page_faultsOptional. Count of hard page faults.

The current_rss is precise on Windows and MacOSX; other systems estimate this using current_commit. The commit is precise on Windows but estimated on other systems as the amount of read/write accessible memory reserved by mimalloc.

◆ mi_process_info_print()

void mi_process_info_print ( void )

Print out all process info.

See also
mi_process_info()

◆ mi_process_info_print_out()

void mi_process_info_print_out ( mi_output_fun * out,
void * arg )

Print out all process info.

Parameters
outAn output function or NULL for the default.
argOptional argument passed to out (if not NULL)
See also
mi_process_print()

◆ mi_stats_as_json()

char * mi_stats_as_json ( mi_stats_t * stats,
size_t buf_size,
char * buf )

v3: Show the given statistics as JSON.

Parameters
statsThe statistics.
buf_sizeByte size of the buffer buf (or 0 if buf is NULL).
bufThe buffer. Pass NULL to allocate a fresh buffer.
Returns
Pointer to the buffer or NULL on failure. Use mi_free() to free the buffer if the buf parameter was NULL.

◆ mi_stats_get()

bool mi_stats_get ( mi_stats_t * stats)

Get the statistics for the current subprocess aggregated over all its heaps.

Parameters
statsPointer to a mi_stats_t() structure (declared as mi_stats_t_decl(name)).
Returns
true if stats is not NULL, and if stats->size and stats->version match the sizeof(mi_stats_t) and MI_STAT_VERSION with the linked mimalloc version.

◆ mi_stats_get_bin_size()

size_t mi_stats_get_bin_size ( size_t bin)

v3: Return the block size for the given bin.

◆ mi_stats_get_json()

char * mi_stats_get_json ( size_t buf_size,
char * buf )

Get the statistics for the current subprocess aggregated over all its heaps as JSON.

Parameters
buf_sizeByte size of the buffer buf (or 0 if buf is NULL)
bufThe buffer. Pass NULL to allocate a fresh buffer.
Returns
Pointer to the buffer or NULL on failure. Use mi_free() to free the buffer if the buf parameter was NULL.

◆ mi_stats_merge()

void mi_stats_merge ( void )

v1,v2: Merge thread local statistics with the main statistics and reset.

◆ mi_stats_print()

void mi_stats_print ( void * out)

Deprecated.

Parameters
outIgnored, outputs to the registered output function or stderr by default.

Most detailed when using a debug build.

◆ mi_stats_print_out()

void mi_stats_print_out ( mi_output_fun * out,
void * arg )

Print statistics of the current subprocess aggregated over all its heaps.

Parameters
outAn output function or NULL for the default.
argOptional argument passed to out (if not NULL)

Most detailed when using a debug build.

◆ mi_stats_reset()

void mi_stats_reset ( void )

v1,v2: Reset statistics.

◆ mi_subproc_heap_stats_print_out()

void mi_subproc_heap_stats_print_out ( mi_subproc_id_t subproc_id,
mi_output_fun * out,
void * arg )

v3: Print statistics for a given subprocess with each heap separately printed.

Parameters
subproc_idThe subprocess
outAn output function or NULL for the default.
argOptional argument passed to out (if not NULL)

◆ mi_subproc_stats_get()

bool mi_subproc_stats_get ( mi_subproc_id_t subproc_id,
mi_stats_t * stats )

v3: Get statistics for a given subprocess aggregated over all its heaps.

Parameters
subproc_idThe subprocess
statsPointer to a mi_stats_t() structure (declared as mi_stats_t_decl(name)).
Returns
true if stats is not NULL, and if stats->size and stats->version match the sizeof(mi_stats_t) and MI_STAT_VERSION with the linked mimalloc version.

◆ mi_subproc_stats_get_json()

char * mi_subproc_stats_get_json ( mi_subproc_id_t subproc_id,
size_t buf_size,
char * buf )

v3: Show the subproc statistics aggregated over all its heaps as JSON.

Parameters
subproc_idThe subprocess.
buf_sizeByte size of the buffer buf (or 0 if buf is NULL).
bufThe buffer. Pass NULL to allocate a fresh buffer.
Returns
Pointer to the buffer or NULL on failure. Use mi_free() to free the buffer if the buf parameter was NULL.

◆ mi_subproc_stats_print_out()

void mi_subproc_stats_print_out ( mi_subproc_id_t subproc_id,
mi_output_fun * out,
void * arg )

v3: Print the subproc statistics aggregated over all its heaps.

Parameters
subproc_idThe subprocess.
outAn output function or NULL for the default.
argOptional argument passed to out (if not NULL)