| mi-malloc 1.8/2.1 |

Loading...
Searching...
No Matches
Data Structures | Macros | Functions
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:

mi_stats_t_decl(stats);
if (mi_stats_get(&stats)) {
...
}
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 versi...
Definition mimalloc-doc.h:1050
mi_stats_get
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

  heap | The heap.
  stats | Pointer 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

  heap | The heap.
  buf_size | Byte size of the buffer buf (or 0 if buf is NULL).
  buf | The 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

  heap | The 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

  heap | The heap.
  out | An output function or NULL for the default.
  arg | Optional 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_msecs | Optional. Elapsed wall-clock time of the process in milli-seconds.
  user_msecs | Optional. User time in milli-seconds (as the sum over all threads).
  system_msecs | Optional. System time in milli-seconds.
  current_rss | Optional. Current working set size (touched pages).
  peak_rss | Optional. Peak working set size (touched pages).
  current_commit | Optional. Current committed memory (backed by the page file).
  peak_commit | Optional. Peak committed memory (backed by the page file).
  page_faults | Optional. 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

  out | An output function or NULL for the default.
  arg | Optional 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

  stats | The statistics.
  buf_size | Byte size of the buffer buf (or 0 if buf is NULL).
  buf | The 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

  stats | Pointer 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_size | Byte size of the buffer buf (or 0 if buf is NULL)
  buf | The 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

  out | Ignored, 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

  out | An output function or NULL for the default.
  arg | Optional 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_id | The subprocess
  out | An output function or NULL for the default.
  arg | Optional 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_id | The subprocess
  stats | Pointer 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_id | The subprocess.
  buf_size | Byte size of the buffer buf (or 0 if buf is NULL).
  buf | The 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_id | The subprocess.
  out | An output function or NULL for the default.
  arg | Optional argument passed to out (if not NULL)