mi-malloc: mimalloc-doc.h Source File

| mi-malloc 1.8/2.1 |

Loading...
Searching...
No Matches
mimalloc-doc.h
1/* ----------------------------------------------------------------------------
2Copyright (c) 2018-2025, Microsoft Research, Daan Leijen
3This is free software; you can redistribute it and/or modify it under the
4terms of the MIT license. A copy of the license can be found in the file
5"LICENSE" at the root of this distribution.
6-----------------------------------------------------------------------------*/
7
8#error "documentation file only!"
9
10
121
122
126 void mi_free(void* p);
127
132 void* mi_malloc(size_t size);
133
138 void* mi_zalloc(size_t size);
139
149 void* mi_calloc(size_t count, size_t size);
150
164 void* mi_realloc(void* p, size_t newsize);
165
179 void* mi_expand(void* p, size_t newsize);
180
190 void* mi_mallocn(size_t count, size_t size);
191
201 void* mi_reallocn(void* p, size_t count, size_t size);
202
219 void* mi_reallocf(void* p, size_t newsize);
220
221
230 char* mi_strdup(const char* s);
231
241 char* mi_strndup(const char* s, size_t n);
242
255 char* mi_realpath(const char* fname, char* resolved_name);
256
270 size_t mi_usable_size(void* p);
271
281 size_t mi_good_size(size_t size);
282
284
285
286// ------------------------------------------------------
287// Aligned allocation
288// ------------------------------------------------------
289
297
315 void* mi_malloc_aligned(size_t size, size_t alignment);
316 void* mi_zalloc_aligned(size_t size, size_t alignment);
317 void* mi_calloc_aligned(size_t count, size_t size, size_t alignment);
318 void* mi_realloc_aligned(void* p, size_t newsize, size_t alignment);
319
331 void* mi_malloc_aligned_at(size_t size, size_t alignment, size_t offset);
332 void* mi_zalloc_aligned_at(size_t size, size_t alignment, size_t offset);
333 void* mi_calloc_aligned_at(size_t count, size_t size, size_t alignment, size_t offset);
334 void* mi_realloc_aligned_at(void* p, size_t newsize, size_t alignment, size_t offset);
335
337
338
347
359#define mi_malloc_tp(tp) ((tp*)mi_malloc(sizeof(tp)))
360
362#define mi_zalloc_tp(tp) ((tp*)mi_zalloc(sizeof(tp)))
363
365#define mi_calloc_tp(tp,count) ((tp*)mi_calloc(count,sizeof(tp)))
366
368#define mi_mallocn_tp(tp,count) ((tp*)mi_mallocn(count,sizeof(tp)))
369
371#define mi_reallocn_tp(p,tp,count) ((tp*)mi_reallocn(p,count,sizeof(tp)))
372
374#define mi_heap_malloc_tp(tp,hp) ((tp*)mi_heap_malloc(hp,sizeof(tp)))
375
377#define mi_heap_zalloc_tp(tp,hp) ((tp*)mi_heap_zalloc(hp,sizeof(tp)))
378
380#define mi_heap_calloc_tp(tp,hp,count) ((tp*)mi_heap_calloc(hp,count,sizeof(tp)))
381
383#define mi_heap_mallocn_tp(tp,hp,count) ((tp*)mi_heap_mallocn(hp,count,sizeof(tp)))
384
386#define mi_heap_reallocn_tp(tp,hp,p,count) ((tp*)mi_heap_reallocn(p,count,sizeof(tp)))
387
389#define mi_heap_recalloc_tp(tp,hp,p,count) ((tp*)mi_heap_recalloc(p,count,sizeof(tp)))
390
392
402
413 void* mi_recalloc(void* p, size_t count, size_t size);
414
415 void* mi_rezalloc(void* p, size_t newsize);
416void* mi_recalloc(void* p, size_t newcount, size_t size) ;
417
418 void* mi_rezalloc_aligned(void* p, size_t newsize, size_t alignment);
419 void* mi_rezalloc_aligned_at(void* p, size_t newsize, size_t alignment, size_t offset);
420 void* mi_recalloc_aligned(void* p, size_t newcount, size_t size, size_t alignment);
421 void* mi_recalloc_aligned_at(void* p, size_t newcount, size_t size, size_t alignment, size_t offset);
422
423 void* mi_heap_rezalloc(mi_heap_t* heap, void* p, size_t newsize);
424 void* mi_heap_recalloc(mi_heap_t* heap, void* p, size_t newcount, size_t size);
425
426 void* mi_heap_rezalloc_aligned(mi_heap_t* heap, void* p, size_t newsize, size_t alignment);
427 void* mi_heap_rezalloc_aligned_at(mi_heap_t* heap, void* p, size_t newsize, size_t alignment, size_t offset);
428 void* mi_heap_recalloc_aligned(mi_heap_t* heap, void* p, size_t newcount, size_t size, size_t alignment);
429 void* mi_heap_recalloc_aligned_at(mi_heap_t* heap, void* p, size_t newcount, size_t size, size_t alignment, size_t offset);
430
432
433
434
452
458struct mi_heap_s;
459
465 typedef struct mi_heap_s mi_heap_t;
466
468 mi_heap_t* mi_heap_new();
469
476 void mi_heap_delete(mi_heap_t* heap);
477
484 void mi_heap_destroy(mi_heap_t* heap);
485
490 mi_heap_t* mi_heap_set_default(mi_heap_t* heap);
491
495 mi_heap_t* mi_heap_get_default();
496
503 mi_heap_t* mi_heap_get_backing();
504
508 void mi_heap_set_numa_affinity(mi_heap_t* heap, int numa_node);
509
515 mi_heap_t* mi_heap_main(void);
516
522 mi_heap_t* mi_heap_of(const void* p);
523
528 bool mi_heap_contains(const mi_heap_t* heap, const void* p);
529
533 bool mi_any_heap_contains(const void* p);
534
535
541 bool mi_is_in_heap_region(const void* p);
542
548 bool mi_check_owned(const void* p);
549
556 bool mi_heap_contains_block(mi_heap_t* heap, const void* p);
557
564 bool mi_heap_check_owned(mi_heap_t* heap, const void* p);
565
567 void mi_heap_collect(mi_heap_t* heap, bool force);
568
571 void* mi_heap_malloc(mi_heap_t* heap, size_t size);
572
576 void* mi_heap_malloc_small(mi_heap_t* heap, size_t size);
577
580 void* mi_heap_zalloc(mi_heap_t* heap, size_t size);
581
585 void* mi_heap_zalloc_small(mi_heap_t* heap, size_t size);
586
589 void* mi_heap_calloc(mi_heap_t* heap, size_t count, size_t size);
590
593 void* mi_heap_mallocn(mi_heap_t* heap, size_t count, size_t size);
594
597 char* mi_heap_strdup(mi_heap_t* heap, const char* s);
598
601 char* mi_heap_strndup(mi_heap_t* heap, const char* s, size_t n);
602
605 char* mi_heap_realpath(mi_heap_t* heap, const char* fname, char* resolved_name);
606
607 void* mi_heap_realloc(mi_heap_t* heap, void* p, size_t newsize);
608 void* mi_heap_reallocn(mi_heap_t* heap, void* p, size_t count, size_t size);
609 void* mi_heap_reallocf(mi_heap_t* heap, void* p, size_t newsize);
610
611 void* mi_heap_malloc_aligned(mi_heap_t* heap, size_t size, size_t alignment);
612 void* mi_heap_malloc_aligned_at(mi_heap_t* heap, size_t size, size_t alignment, size_t offset);
613 void* mi_heap_zalloc_aligned(mi_heap_t* heap, size_t size, size_t alignment);
614 void* mi_heap_zalloc_aligned_at(mi_heap_t* heap, size_t size, size_t alignment, size_t offset);
615 void* mi_heap_calloc_aligned(mi_heap_t* heap, size_t count, size_t size, size_t alignment);
616 void* mi_heap_calloc_aligned_at(mi_heap_t* heap, size_t count, size_t size, size_t alignment, size_t offset);
617 void* mi_heap_realloc_aligned(mi_heap_t* heap, void* p, size_t newsize, size_t alignment);
618 void* mi_heap_realloc_aligned_at(mi_heap_t* heap, void* p, size_t newsize, size_t alignment, size_t offset);
619
621
622
623
628
629
632 typedef struct mi_heap_area_s {
633 void* blocks;
634 size_t reserved;
635 size_t committed;
636 size_t used;
637 size_t block_size;
638 size_t full_block_size;
639 int heap_tag;
640} mi_heap_area_t;
641
649 typedef bool (mi_block_visit_fun)(const mi_heap_t* heap, const mi_heap_area_t* area, void* block, size_t block_size, void* arg);
650
665 bool mi_heap_visit_blocks(const mi_heap_t* heap, bool visit_blocks, mi_block_visit_fun* visitor, void* arg);
666
682 bool mi_abandoned_visit_blocks(mi_subproc_id_t subproc_id, int heap_tag, bool visit_blocks, mi_block_visit_fun* visitor, void* arg);
683
685
686// ------------------------------------------------------
687// Arenas
688// ------------------------------------------------------
689
697
699 typedef int mi_arena_id_t;
700
709 int mi_reserve_os_memory(size_t size, bool commit, bool allow_large);
710
718 int mi_reserve_os_memory_ex(size_t size, bool commit, bool allow_large, bool exclusive, mi_arena_id_t* arena_id);
719
732 int mi_reserve_huge_os_pages_interleave(size_t pages, size_t numa_nodes, size_t timeout_msecs);
733
746 int mi_reserve_huge_os_pages_at(size_t pages, int numa_node, size_t timeout_msecs);
747
755 int mi_reserve_huge_os_pages_at_ex(size_t pages, int numa_node, size_t timeout_msecs, bool exclusive, mi_arena_id_t* arena_id);
756
759 size_t mi_arena_min_alignment(void);
760
772 bool mi_manage_os_memory(void* start, size_t size, bool is_committed, bool is_large, bool is_zero, int numa_node);
773
784 bool mi_manage_os_memory_ex(void* start, size_t size, bool is_committed, bool is_large, bool is_zero, int numa_node, bool exclusive, mi_arena_id_t* arena_id);
785
786
788 void mi_debug_show_arenas(void);
789
794 void* mi_arena_area(mi_arena_id_t arena_id, size_t* size);
795
796
797
801 mi_heap_t* mi_heap_new_in_arena(mi_arena_id_t arena_id);
802
814 mi_heap_t* mi_heap_new_ex(int heap_tag, bool allow_destroy, mi_arena_id_t arena_id);
815
817
818
827
832 typedef void* mi_subproc_id_t;
833
835 mi_subproc_id_t mi_subproc_main(void);
836
838 mi_subproc_id_t mi_subproc_current(void);
839
842 mi_subproc_id_t mi_subproc_new(void);
843
847 void mi_subproc_destroy(mi_subproc_id_t subproc);
848
853 void mi_subproc_delete(mi_subproc_id_t subproc);
854
858 void mi_subproc_add_current_thread(mi_subproc_id_t subproc);
859
863 typedef bool (mi_heap_visit_fun)(mi_heap_t* heap, void* arg);
864
870 bool mi_subproc_visit_heaps(mi_subproc_id_t subproc, mi_heap_visit_fun* visitor, void* arg);
871
873
874
875// ------------------------------------------------------
876// Extended functionality
877// ------------------------------------------------------
878
883
887#define MI_SMALL_SIZE_MAX (128*sizeof(void*))
888
892 int mi_version(void);
893
901 void mi_collect(bool force);
902
908 void mi_thread_set_in_threadpool(void);
909
914 bool mi_is_redirected();
915
919 void mi_thread_init(void);
920
925 void mi_thread_done(void);
926
933 typedef void (mi_deferred_free_fun)(bool force, unsigned long long heartbeat, void* arg);
934
950 void mi_register_deferred_free(mi_deferred_free_fun* deferred_free, void* arg);
951
957 typedef void (mi_output_fun)(const char* msg, void* arg);
958
965 void mi_register_output(mi_output_fun* out, void* arg);
966
972 typedef void (mi_error_fun)(int err, void* arg);
973
989 void mi_register_error(mi_error_fun* errfun, void* arg);
990
998 void* mi_malloc_small(size_t size);
999
1007 void* mi_zalloc_small(size_t size);
1008
1022 void mi_free_small(void* p);
1023
1025
1026
1027
1028
1029
1030// ------------------------------------------------------
1031// Statistics
1032// ------------------------------------------------------
1033
1037
1039#define MI_STAT_VERSION 4
1040
1050#define mi_stats_t_decl(name)
1051
1053 struct mi_stats_s {
1055 size_t size;
1057 size_t version;
1058};
1059
1061typedef struct mi_stats_s mi_stats_t;
1062
1063
1066 void mi_process_info_print(void);
1067
1072 void mi_process_info_print_out(mi_output_fun* out, void* arg);
1073
1087 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);
1088
1089
1094 void mi_stats_print(void* out);
1095
1101 void mi_stats_print_out(mi_output_fun* out, void* arg);
1102
1108 bool mi_stats_get(mi_stats_t* stats);
1109
1115 char* mi_stats_get_json(size_t buf_size, char* buf);
1116
1118 size_t mi_stats_get_bin_size(size_t bin);
1119
1126 bool mi_heap_stats_get(mi_heap_t* heap, mi_stats_t* stats);
1127
1134 char* mi_heap_stats_get_json(mi_heap_t* heap, size_t buf_size, char* buf); // use mi_free to free the result if the input buf == NULL
1135
1140 void mi_heap_stats_print_out(mi_heap_t* heap, mi_output_fun* out, void* arg);
1141
1145 void mi_heap_stats_merge_to_subproc(mi_heap_t* heap);
1146
1153 bool mi_subproc_stats_get(mi_subproc_id_t subproc_id, mi_stats_t* stats);
1154
1161 char* mi_subproc_stats_get_json(mi_subproc_id_t subproc_id, size_t buf_size, char* buf); // use mi_free to free the result if the input buf == NULL
1162
1167 void mi_subproc_stats_print_out(mi_subproc_id_t subproc_id, mi_output_fun* out, void* arg);
1168
1169
1174 void mi_subproc_heap_stats_print_out(mi_subproc_id_t subproc_id, mi_output_fun* out, void* arg);
1175
1182 char* mi_stats_as_json( mi_stats_t* stats, size_t buf_size, char* buf);
1183
1185 void mi_stats_reset(void);
1186
1188 void mi_stats_merge(void);
1189
1191
1192// ------------------------------------------------------
1193// Runtime Options
1194// ------------------------------------------------------
1195
1200
1203 void mi_options_print(void);
1204
1210 void mi_options_print_out(mi_output_fun* out, void* arg);
1211
1212
1214 typedef enum mi_option_e {
1215 // stable options
1216 mi_option_show_errors,
1217 mi_option_show_stats,
1218 mi_option_verbose,
1219 mi_option_max_errors,
1220 mi_option_max_warnings,
1221
1222 // advanced options
1223 mi_option_reserve_huge_os_pages,
1224 mi_option_reserve_huge_os_pages_at,
1225 mi_option_reserve_os_memory,
1226 mi_option_allow_large_os_pages,
1227 mi_option_purge_decommits,
1228 mi_option_arena_reserve,
1229 mi_option_os_tag,
1230 mi_option_retry_on_oom,
1231 mi_option_generic_collect,
1232 mi_option_allow_thp,
1233
1234 // guard pages
1235 mi_option_guarded_min,
1236 mi_option_guarded_max,
1237 mi_option_guarded_precise,
1238 mi_option_guarded_sample_rate,
1239 mi_option_guarded_sample_seed,
1240
1241 // experimental options
1242 mi_option_eager_commit,
1243 mi_option_eager_commit_delay,
1244 mi_option_arena_eager_commit,
1245 mi_option_abandoned_page_purge,
1246 mi_option_purge_delay,
1247 mi_option_use_numa_nodes,
1248 mi_option_disallow_os_alloc,
1249 mi_option_max_segment_reclaim,
1250 mi_option_destroy_on_exit,
1251 mi_option_arena_purge_mult,
1252 mi_option_abandoned_reclaim_on_free,
1253 mi_option_purge_extend_delay,
1254 mi_option_disallow_arena_alloc,
1255 mi_option_visit_abandoned,
1256 mi_option_target_segments_per_thread,
1257
1258 // v3 options
1259 mi_option_page_reclaim_on_free,
1260 mi_option_page_full_retain,
1261 mi_option_page_max_candidates,
1262 mi_option_max_vabits,
1263 mi_option_pagemap_commit,
1264 mi_option_page_commit_on_demand,
1265 mi_option_page_max_reclaim,
1266 mi_option_page_cross_thread_max_reclaim,
1267 mi_option_minimal_purge_size,
1268 mi_option_arena_max_object_size,
1269
1270 _mi_option_last
1271} mi_option_t;
1272
1273
1274 bool mi_option_is_enabled(mi_option_t option);
1275 void mi_option_enable(mi_option_t option);
1276 void mi_option_disable(mi_option_t option);
1277 void mi_option_set_enabled(mi_option_t option, bool enable);
1278 void mi_option_set_enabled_default(mi_option_t option, bool enable);
1279
1280 long mi_option_get(mi_option_t option);
1281 long mi_option_get_clamp(mi_option_t option, long min, long max);
1282 size_t mi_option_get_size(mi_option_t option);
1283
1284 void mi_option_set(mi_option_t option, long value);
1285 void mi_option_set_default(mi_option_t option, long value);
1286
1288
1301
1303struct mi_theap_s;
1304
1306 typedef struct mi_theap_s mi_theap_t;
1307
1314 mi_theap_t* mi_heap_theap(mi_heap_t* heap);
1315
1317 void mi_theap_collect(mi_theap_t* theap, bool force);
1318
1323 mi_theap_t* mi_theap_set_default(mi_theap_t* theap);
1324
1327 mi_theap_t* mi_theap_get_default();
1328
1331 void* mi_theap_malloc(mi_theap_t* theap, size_t size);
1332
1336 void* mi_theap_malloc_small(mi_theap_t* theap, size_t size);
1337
1340 void* mi_theap_zalloc(mi_theap_t* theap, size_t size);
1341
1345 void* mi_theap_zalloc_small(mi_theap_t* theap, size_t size);
1346
1347 void* mi_theap_calloc(mi_theap_t* theap, size_t count, size_t size);
1348 void* mi_theap_malloc_aligned(mi_theap_t* theap, size_t size, size_t alignment);
1349 void* mi_theap_realloc(mi_theap_t* theap, void* p, size_t newsize);
1350
1352
1353
1359
1361 void mi_cfree(void* p);
1362 void* mi__expand(void* p, size_t newsize);
1363
1364 size_t mi_malloc_size(const void* p);
1365 size_t mi_malloc_good_size(size_t size);
1366 size_t mi_malloc_usable_size(const void *p);
1367
1368 int mi_posix_memalign(void** p, size_t alignment, size_t size);
1369 int mi__posix_memalign(void** p, size_t alignment, size_t size);
1370 void* mi_memalign(size_t alignment, size_t size);
1371 void* mi_valloc(size_t size);
1372 void* mi_pvalloc(size_t size);
1373 void* mi_aligned_alloc(size_t alignment, size_t size);
1374
1375 unsigned short* mi_wcsdup(const unsigned short* s);
1376 unsigned char* mi_mbsdup(const unsigned char* s);
1377 int mi_dupenv_s(char** buf, size_t* size, const char* name);
1378 int mi_wdupenv_s(unsigned short** buf, size_t* size, const unsigned short* name);
1379
1382 void* mi_reallocarray(void* p, size_t count, size_t size);
1383
1385 int mi_reallocarr(void* p, size_t count, size_t size);
1386
1387 void* mi_aligned_recalloc(void* p, size_t newcount, size_t size, size_t alignment);
1388 void* mi_aligned_offset_recalloc(void* p, size_t newcount, size_t size, size_t alignment, size_t offset);
1389
1390 void mi_free_size(void* p, size_t size);
1391 void mi_free_size_aligned(void* p, size_t size, size_t alignment);
1392 void mi_free_aligned(void* p, size_t alignment);
1393
1395
1408
1410 void* mi_new(std::size_t n) noexcept(false);
1411
1413 void* mi_new_n(size_t count, size_t size) noexcept(false);
1414
1416 void* mi_new_aligned(std::size_t n, std::align_val_t alignment) noexcept(false);
1417
1419 void* mi_new_nothrow(size_t n);
1420
1422 void* mi_new_aligned_nothrow(size_t n, size_t alignment);
1423
1425 void* mi_new_realloc(void* p, size_t newsize);
1426
1428 void* mi_new_reallocn(void* p, size_t newcount, size_t size);
1429
1437 template<class T> struct mi_stl_allocator { }
1438
1440
mi_malloc_aligned_at
void * mi_malloc_aligned_at(size_t size, size_t alignment, size_t offset)
Allocate size bytes aligned by alignment at a specified offset.
mi_calloc_aligned
void * mi_calloc_aligned(size_t count, size_t size, size_t alignment)
mi_realloc_aligned
void * mi_realloc_aligned(void *p, size_t newsize, size_t alignment)
mi_malloc_aligned
void * mi_malloc_aligned(size_t size, size_t alignment)
Allocate size bytes aligned by alignment.
mi_zalloc_aligned_at
void * mi_zalloc_aligned_at(size_t size, size_t alignment, size_t offset)
mi_calloc_aligned_at
void * mi_calloc_aligned_at(size_t count, size_t size, size_t alignment, size_t offset)
mi_zalloc_aligned
void * mi_zalloc_aligned(size_t size, size_t alignment)
mi_realloc_aligned_at
void * mi_realloc_aligned_at(void *p, size_t newsize, size_t alignment, size_t offset)
mi_heap_area_t::heap_tag
int heap_tag
heap tag associated with this area (see mi_heap_new_ex)
Definition mimalloc-doc.h:639
mi_heap_area_t::block_size
size_t block_size
size in bytes of one block
Definition mimalloc-doc.h:637
mi_heap_area_t::committed
size_t committed
current committed bytes of this area
Definition mimalloc-doc.h:635
mi_heap_area_t::full_block_size
size_t full_block_size
size in bytes of a full block including padding and metadata.
Definition mimalloc-doc.h:638
mi_heap_area_t::used
size_t used
bytes in use by allocated blocks
Definition mimalloc-doc.h:636
mi_heap_area_t::blocks
void * blocks
start of the area containing heap blocks
Definition mimalloc-doc.h:633
mi_heap_area_t::reserved
size_t reserved
bytes reserved for this area
Definition mimalloc-doc.h:634
mi_abandoned_visit_blocks
bool mi_abandoned_visit_blocks(mi_subproc_id_t subproc_id, int heap_tag, bool visit_blocks, mi_block_visit_fun *visitor, void *arg)
v1,v2: Visit all areas and blocks in abandoned heaps.
mi_block_visit_fun
bool mi_block_visit_fun(const mi_heap_t *heap, const mi_heap_area_t *area, void *block, size_t block_size, void *arg)
Visitor function passed to mi_heap_visit_blocks()
Definition mimalloc-doc.h:649
mi_heap_visit_blocks
bool mi_heap_visit_blocks(const mi_heap_t *heap, bool visit_blocks, mi_block_visit_fun *visitor, void *arg)
Visit all areas and blocks in a heap.
mi_heap_area_t
An area of heap space contains blocks of a single size.
Definition mimalloc-doc.h:632
mi_reserve_os_memory
int mi_reserve_os_memory(size_t size, bool commit, bool allow_large)
Reserve OS memory for use by mimalloc.
mi_reserve_huge_os_pages_interleave
int mi_reserve_huge_os_pages_interleave(size_t pages, size_t numa_nodes, size_t timeout_msecs)
Reserve pages of huge OS pages (1GiB) evenly divided over numa_nodes nodes, but stops after at most t...
mi_reserve_os_memory_ex
int mi_reserve_os_memory_ex(size_t size, bool commit, bool allow_large, bool exclusive, mi_arena_id_t *arena_id)
Reserve OS memory to be managed in an arena.
mi_heap_new_ex
mi_heap_t * mi_heap_new_ex(int heap_tag, bool allow_destroy, mi_arena_id_t arena_id)
v1,v2: Create a new heap.
mi_manage_os_memory_ex
bool mi_manage_os_memory_ex(void *start, size_t size, bool is_committed, bool is_large, bool is_zero, int numa_node, bool exclusive, mi_arena_id_t *arena_id)
Manage externally allocated memory as a mimalloc arena.
mi_manage_os_memory
bool mi_manage_os_memory(void *start, size_t size, bool is_committed, bool is_large, bool is_zero, int numa_node)
Manage a particular memory area for use by mimalloc.
mi_reserve_huge_os_pages_at_ex
int mi_reserve_huge_os_pages_at_ex(size_t pages, int numa_node, size_t timeout_msecs, bool exclusive, mi_arena_id_t *arena_id)
Reserve huge OS pages (1GiB) into a single arena.
mi_reserve_huge_os_pages_at
int mi_reserve_huge_os_pages_at(size_t pages, int numa_node, size_t timeout_msecs)
Reserve pages of huge OS pages (1GiB) at a specific numa_node, but stops after at most timeout_msecs ...
mi_debug_show_arenas
void mi_debug_show_arenas(void)
Show all current arena's.
mi_arena_id_t
int mi_arena_id_t
Each arena has an associated identifier.
Definition mimalloc-doc.h:699
mi_arena_area
void * mi_arena_area(mi_arena_id_t arena_id, size_t *size)
Return the start and size of an arena.
mi_arena_min_alignment
size_t mi_arena_min_alignment(void)
Return the minimal alignment required for managed OS memory.
mi_heap_new_in_arena
mi_heap_t * mi_heap_new_in_arena(mi_arena_id_t arena_id)
Create a new heap that only allocates in the specified arena.
mi_new_nothrow
void * mi_new_nothrow(size_t n)
like mi_malloc, but when out of memory, use std::get_new_handler but return NULL on failure.
mi_new
void * mi_new(std::size_t n) noexcept(false)
like mi_malloc(), but when out of memory, use std::get_new_handler and raise std::bad_alloc exception...
mi_new_realloc
void * mi_new_realloc(void *p, size_t newsize)
like mi_realloc(), but when out of memory, use std::get_new_handler and raise std::bad_alloc exceptio...
mi_new_aligned
void * mi_new_aligned(std::size_t n, std::align_val_t alignment) noexcept(false)
like mi_malloc_aligned(), but when out of memory, use std::get_new_handler and raise std::bad_alloc e...
mi_new_aligned_nothrow
void * mi_new_aligned_nothrow(size_t n, size_t alignment)
like mi_malloc_aligned, but when out of memory, use std::get_new_handler but return NULL on failure.
mi_new_reallocn
void * mi_new_reallocn(void *p, size_t newcount, size_t size)
like mi_reallocn(), but when out of memory, use std::get_new_handler and raise std::bad_alloc excepti...
mi_new_n
void * mi_new_n(size_t count, size_t size) noexcept(false)
like mi_mallocn(), but when out of memory, use std::get_new_handler and raise std::bad_alloc exceptio...
mi_stl_allocator
std::allocator implementation for mimalloc for use in STL containers. For example:
Definition mimalloc-doc.h:1437
mi_thread_done
void mi_thread_done(void)
Uninitialize mimalloc on a thread.
mi_deferred_free_fun
void mi_deferred_free_fun(bool force, unsigned long long heartbeat, void *arg)
Type of deferred free functions.
Definition mimalloc-doc.h:933
mi_free_small
void mi_free_small(void *p)
v3: Can be used to free an object that was allocated with mi_malloc_small et al.
mi_register_deferred_free
void mi_register_deferred_free(mi_deferred_free_fun *deferred_free, void *arg)
Register a deferred free function.
mi_collect
void mi_collect(bool force)
Eagerly free memory.
mi_zalloc_small
void * mi_zalloc_small(size_t size)
Allocate a zero initialized small object.
mi_malloc_small
void * mi_malloc_small(size_t size)
Allocate a small object.
mi_error_fun
void mi_error_fun(int err, void *arg)
Type of error callback functions.
Definition mimalloc-doc.h:972
mi_register_error
void mi_register_error(mi_error_fun *errfun, void *arg)
Register an error callback function.
mi_is_redirected
bool mi_is_redirected()
Is the C runtime malloc API redirected?
mi_thread_set_in_threadpool
void mi_thread_set_in_threadpool(void)
v3: Communicate that a thread is in a threadpool.
mi_output_fun
void mi_output_fun(const char *msg, void *arg)
Type of output functions.
Definition mimalloc-doc.h:957
mi_register_output
void mi_register_output(mi_output_fun *out, void *arg)
Register an output function.
mi_version
int mi_version(void)
Return the mimalloc version.
mi_thread_init
void mi_thread_init(void)
Initialize mimalloc on a thread.
mi_heap_malloc_small
void * mi_heap_malloc_small(mi_heap_t *heap, size_t size)
Allocate a small object in a specific heap.
mi_heap_zalloc_small
void * mi_heap_zalloc_small(mi_heap_t *heap, size_t size)
Allocate a small object in a specific heap.
mi_heap_check_owned
bool mi_heap_check_owned(mi_heap_t *heap, const void *p)
v1,v2: Check safely if any pointer is part of a heap.
mi_heap_get_default
mi_heap_t * mi_heap_get_default()
v1,v2: Get the default heap that is used for mi_malloc() et al.
mi_any_heap_contains
bool mi_any_heap_contains(const void *p)
v3: is a pointer pointing into mimalloc managed memory?
mi_heap_delete
void mi_heap_delete(mi_heap_t *heap)
Delete a previously allocated heap.
mi_heap_malloc_aligned
void * mi_heap_malloc_aligned(mi_heap_t *heap, size_t size, size_t alignment)
mi_heap_set_default
mi_heap_t * mi_heap_set_default(mi_heap_t *heap)
v1,v2: Set the default heap to use in the current thread for mi_malloc() et al.
mi_heap_t
struct mi_heap_s mi_heap_t
Type of first-class heaps.
Definition mimalloc-doc.h:465
mi_heap_of
mi_heap_t * mi_heap_of(const void *p)
v3: return the heap that contains the given pointer.
mi_heap_zalloc_aligned_at
void * mi_heap_zalloc_aligned_at(mi_heap_t *heap, size_t size, size_t alignment, size_t offset)
mi_heap_realpath
char * mi_heap_realpath(mi_heap_t *heap, const char *fname, char *resolved_name)
Resolve a file path name using a specific heap to allocate the result.
mi_heap_strdup
char * mi_heap_strdup(mi_heap_t *heap, const char *s)
Duplicate a string in a specific heap.
mi_is_in_heap_region
bool mi_is_in_heap_region(const void *p)
v1,v2: Is a pointer part of our heap?
mi_check_owned
bool mi_check_owned(const void *p)
v1,v2: Check if any pointer is part of the default heap of this thread.
mi_heap_zalloc_aligned
void * mi_heap_zalloc_aligned(mi_heap_t *heap, size_t size, size_t alignment)
mi_heap_realloc_aligned_at
void * mi_heap_realloc_aligned_at(mi_heap_t *heap, void *p, size_t newsize, size_t alignment, size_t offset)
mi_heap_collect
void mi_heap_collect(mi_heap_t *heap, bool force)
Release outstanding resources in a specific heap.
mi_heap_main
mi_heap_t * mi_heap_main(void)
v3: the main heap (of the current sub-process)
mi_heap_destroy
void mi_heap_destroy(mi_heap_t *heap)
Destroy a heap, freeing all its still allocated blocks.
mi_heap_calloc_aligned_at
void * mi_heap_calloc_aligned_at(mi_heap_t *heap, size_t count, size_t size, size_t alignment, size_t offset)
mi_heap_new
mi_heap_t * mi_heap_new()
Create a new heap that can be used for allocation.
mi_heap_contains_block
bool mi_heap_contains_block(mi_heap_t *heap, const void *p)
v1,v2: Does a heap contain a pointer to a previously allocated block?
mi_heap_set_numa_affinity
void mi_heap_set_numa_affinity(mi_heap_t *heap, int numa_node)
v3: set NUMA affinity for a heap.
mi_heap_mallocn
void * mi_heap_mallocn(mi_heap_t *heap, size_t count, size_t size)
Allocate count elements in a specific heap.
mi_heap_malloc
void * mi_heap_malloc(mi_heap_t *heap, size_t size)
Allocate in a specific heap.
mi_heap_zalloc
void * mi_heap_zalloc(mi_heap_t *heap, size_t size)
Allocate zero-initialized in a specific heap.
mi_heap_calloc
void * mi_heap_calloc(mi_heap_t *heap, size_t count, size_t size)
Allocate count zero-initialized elements in a specific heap.
mi_heap_realloc
void * mi_heap_realloc(mi_heap_t *heap, void *p, size_t newsize)
mi_heap_get_backing
mi_heap_t * mi_heap_get_backing()
v1,v2: Get the backing heap.
mi_heap_contains
bool mi_heap_contains(const mi_heap_t *heap, const void *p)
v3: does a heap contain a specific pointer?
mi_heap_calloc_aligned
void * mi_heap_calloc_aligned(mi_heap_t *heap, size_t count, size_t size, size_t alignment)
mi_heap_reallocn
void * mi_heap_reallocn(mi_heap_t *heap, void *p, size_t count, size_t size)
mi_heap_realloc_aligned
void * mi_heap_realloc_aligned(mi_heap_t *heap, void *p, size_t newsize, size_t alignment)
mi_heap_strndup
char * mi_heap_strndup(mi_heap_t *heap, const char *s, size_t n)
Duplicate a string of at most length n in a specific heap.
mi_heap_reallocf
void * mi_heap_reallocf(mi_heap_t *heap, void *p, size_t newsize)
mi_heap_malloc_aligned_at
void * mi_heap_malloc_aligned_at(mi_heap_t *heap, size_t size, size_t alignment, size_t offset)
mi_realloc
void * mi_realloc(void *p, size_t newsize)
Re-allocate memory to newsize bytes.
mi_usable_size
size_t mi_usable_size(void *p)
Return the available bytes in a memory block.
mi_expand
void * mi_expand(void *p, size_t newsize)
Try to re-allocate memory to newsize bytes in place.
mi_strdup
char * mi_strdup(const char *s)
Allocate and duplicate a string.
mi_strndup
char * mi_strndup(const char *s, size_t n)
Allocate and duplicate a string up to n bytes.
mi_reallocf
void * mi_reallocf(void *p, size_t newsize)
Re-allocate memory to newsize bytes,.
mi_mallocn
void * mi_mallocn(size_t count, size_t size)
Allocate count elements of size bytes.
mi_calloc
void * mi_calloc(size_t count, size_t size)
Allocate zero-initialized count elements of size bytes.
mi_reallocn
void * mi_reallocn(void *p, size_t count, size_t size)
Re-allocate memory to count elements of size bytes.
mi_realpath
char * mi_realpath(const char *fname, char *resolved_name)
Resolve a file path name.
mi_good_size
size_t mi_good_size(size_t size)
Return the probable allocation block size for a given required size.
mi_malloc
void * mi_malloc(size_t size)
Allocate size bytes.
mi_zalloc
void * mi_zalloc(size_t size)
Allocate zero-initialized size bytes.
mi_free
void mi_free(void *p)
Free previously allocated memory.
mi_option_enable
void mi_option_enable(mi_option_t option)
mi_options_print_out
void mi_options_print_out(mi_output_fun *out, void *arg)
Print out all process info.
mi_option_get_size
size_t mi_option_get_size(mi_option_t option)
mi_option_is_enabled
bool mi_option_is_enabled(mi_option_t option)
mi_option_set_enabled_default
void mi_option_set_enabled_default(mi_option_t option, bool enable)
mi_option_get
long mi_option_get(mi_option_t option)
mi_option_set_default
void mi_option_set_default(mi_option_t option, long value)
mi_option_get_clamp
long mi_option_get_clamp(mi_option_t option, long min, long max)
mi_option_set_enabled
void mi_option_set_enabled(mi_option_t option, bool enable)
mi_option_disable
void mi_option_disable(mi_option_t option)
mi_options_print
void mi_options_print(void)
Print out all runtime parameters for mimalloc. Also printed with MIMALLOC_VERBOSE=1 at startup.
mi_option_set
void mi_option_set(mi_option_t option, long value)
mi_option_t
mi_option_t
Runtime options.
Definition mimalloc-doc.h:1214
mi_option_guarded_min
@ mi_option_guarded_min
only used when building with MI_GUARDED: minimal rounded object size for guarded objects (=0)
Definition mimalloc-doc.h:1235
mi_option_abandoned_reclaim_on_free
@ mi_option_abandoned_reclaim_on_free
v1,v2: allow to reclaim an abandoned segment on a free (=1)
Definition mimalloc-doc.h:1252
mi_option_purge_extend_delay
@ mi_option_purge_extend_delay
v1,v2: extend purge delay on each subsequent delay (=1)
Definition mimalloc-doc.h:1253
mi_option_allow_thp
@ mi_option_allow_thp
allow transparent huge pages? (=1) (on Android =0 by default). Set to 0 to disable THP for the proces...
Definition mimalloc-doc.h:1232
mi_option_show_stats
@ mi_option_show_stats
Print statistics on termination.
Definition mimalloc-doc.h:1217
mi_option_use_numa_nodes
@ mi_option_use_numa_nodes
0 = use all available numa nodes, otherwise use at most N nodes.
Definition mimalloc-doc.h:1247
mi_option_page_max_reclaim
@ mi_option_page_max_reclaim
v3: don't reclaim pages of the same originating theap if we already own N pages (in that size class) ...
Definition mimalloc-doc.h:1265
mi_option_abandoned_page_purge
@ mi_option_abandoned_page_purge
v1,v2: immediately purge delayed purges on thread termination
Definition mimalloc-doc.h:1245
mi_option_eager_commit_delay
@ mi_option_eager_commit_delay
v2: the first N segments per thread are not eagerly committed (but per page in the segment on demand)
Definition mimalloc-doc.h:1243
mi_option_eager_commit
@ mi_option_eager_commit
v1,v2: eager commit segments? (after eager_commit_delay segments) (enabled by default).
Definition mimalloc-doc.h:1242
mi_option_guarded_precise
@ mi_option_guarded_precise
disregard minimal alignment requirement to always place guarded blocks exactly in front of a guard pa...
Definition mimalloc-doc.h:1237
mi_option_visit_abandoned
@ mi_option_visit_abandoned
allow visiting heap blocks from abandoned threads (=0)
Definition mimalloc-doc.h:1255
mi_option_os_tag
@ mi_option_os_tag
tag used for OS logging (macOS only for now) (=100)
Definition mimalloc-doc.h:1229
mi_option_arena_max_object_size
@ mi_option_arena_max_object_size
v3: set maximal object size that can be allocated in an arena (in KiB) (=2GiB on 64-bit).
Definition mimalloc-doc.h:1268
mi_option_minimal_purge_size
@ mi_option_minimal_purge_size
v3: set minimal purge size (in KiB) (=0). By default set to either 64 or 2048 if THP is enabled....
Definition mimalloc-doc.h:1267
_mi_option_last
@ _mi_option_last
Definition mimalloc-doc.h:1270
mi_option_destroy_on_exit
@ mi_option_destroy_on_exit
if set, release all memory on exit; sometimes used for dynamic unloading but can be unsafe
Definition mimalloc-doc.h:1250
mi_option_page_cross_thread_max_reclaim
@ mi_option_page_cross_thread_max_reclaim
v3: don't reclaim pages across threads if we already own N pages (in that size class) (=16)
Definition mimalloc-doc.h:1266
mi_option_page_commit_on_demand
@ mi_option_page_commit_on_demand
v3: commit page memory on-demand (=0)
Definition mimalloc-doc.h:1264
mi_option_guarded_sample_seed
@ mi_option_guarded_sample_seed
can be set to allow for a (more) deterministic re-execution when a guard page is triggered (=0)
Definition mimalloc-doc.h:1239
mi_option_verbose
@ mi_option_verbose
Print verbose messages.
Definition mimalloc-doc.h:1218
mi_option_allow_large_os_pages
@ mi_option_allow_large_os_pages
allow large (2 or 4 MiB) OS pages, implies eager commit.
Definition mimalloc-doc.h:1226
mi_option_arena_purge_mult
@ mi_option_arena_purge_mult
multiplier for purge_delay for the purging delay for arenas (=10)
Definition mimalloc-doc.h:1251
mi_option_target_segments_per_thread
@ mi_option_target_segments_per_thread
v1,v2: experimental (=0)
Definition mimalloc-doc.h:1256
mi_option_generic_collect
@ mi_option_generic_collect
collect heaps every N (=10000) generic allocation calls
Definition mimalloc-doc.h:1231
mi_option_retry_on_oom
@ mi_option_retry_on_oom
retry on out-of-memory for N milli seconds (=400), set to 0 to disable retries. (only on windows)
Definition mimalloc-doc.h:1230
mi_option_guarded_max
@ mi_option_guarded_max
only used when building with MI_GUARDED: maximal rounded object size for guarded objects (=0)
Definition mimalloc-doc.h:1236
mi_option_purge_decommits
@ mi_option_purge_decommits
should a memory purge decommit? (=1). Set to 0 to use memory reset on a purge (instead of decommit)
Definition mimalloc-doc.h:1227
mi_option_reserve_huge_os_pages_at
@ mi_option_reserve_huge_os_pages_at
Reserve N huge OS pages at a specific NUMA node N.
Definition mimalloc-doc.h:1224
mi_option_pagemap_commit
@ mi_option_pagemap_commit
v3: commit the full pagemap (to always catch invalid pointer uses) (=0)
Definition mimalloc-doc.h:1263
mi_option_max_segment_reclaim
@ mi_option_max_segment_reclaim
v2: max. percentage of the abandoned segments can be reclaimed per try (=10%)
Definition mimalloc-doc.h:1249
mi_option_max_vabits
@ mi_option_max_vabits
v3: max user space virtual address bits to consider (=48)
Definition mimalloc-doc.h:1262
mi_option_arena_reserve
@ mi_option_arena_reserve
initial memory size for arena reservation (= 1 GiB on 64-bit) (internally, this value is in KiB; use ...
Definition mimalloc-doc.h:1228
mi_option_page_reclaim_on_free
@ mi_option_page_reclaim_on_free
v3: reclaim abandoned pages on a free (=0). -1 disallowr always, 0 allows if the page originated from...
Definition mimalloc-doc.h:1259
mi_option_reserve_huge_os_pages
@ mi_option_reserve_huge_os_pages
reserve N huge OS pages (1GiB pages) at startup
Definition mimalloc-doc.h:1223
mi_option_page_max_candidates
@ mi_option_page_max_candidates
v3: max candidate pages to consider for allocation (=4)
Definition mimalloc-doc.h:1261
mi_option_disallow_os_alloc
@ mi_option_disallow_os_alloc
1 = do not use OS memory for allocation (but only programmatically reserved arenas)
Definition mimalloc-doc.h:1248
mi_option_purge_delay
@ mi_option_purge_delay
memory purging is delayed by N milli seconds; use 0 for immediate purging or -1 for no purging at all...
Definition mimalloc-doc.h:1246
mi_option_disallow_arena_alloc
@ mi_option_disallow_arena_alloc
1 = do not use arena's for allocation (except if using specific arena id's)
Definition mimalloc-doc.h:1254
mi_option_guarded_sample_rate
@ mi_option_guarded_sample_rate
1 out of N allocations in the min/max range will be guarded (=1000)
Definition mimalloc-doc.h:1238
mi_option_max_errors
@ mi_option_max_errors
issue at most N error messages
Definition mimalloc-doc.h:1219
mi_option_page_full_retain
@ mi_option_page_full_retain
v3: retain N full (small) pages per size class (=2). Use -1 for infinite (as in v1,...
Definition mimalloc-doc.h:1260
mi_option_max_warnings
@ mi_option_max_warnings
issue at most N warning messages
Definition mimalloc-doc.h:1220
mi_option_show_errors
@ mi_option_show_errors
Print error messages.
Definition mimalloc-doc.h:1216
mi_option_reserve_os_memory
@ mi_option_reserve_os_memory
reserve specified amount of OS memory in an arena at startup (internally, this value is in KiB; use m...
Definition mimalloc-doc.h:1225
mi_option_arena_eager_commit
@ mi_option_arena_eager_commit
eager commit arenas? Use 2 to enable just on overcommit systems (=2)
Definition mimalloc-doc.h:1244
mi_malloc_usable_size
size_t mi_malloc_usable_size(const void *p)
mi_free_aligned
void mi_free_aligned(void *p, size_t alignment)
mi_aligned_offset_recalloc
void * mi_aligned_offset_recalloc(void *p, size_t newcount, size_t size, size_t alignment, size_t offset)
mi_aligned_alloc
void * mi_aligned_alloc(size_t alignment, size_t size)
mi_malloc_size
size_t mi_malloc_size(const void *p)
mi_valloc
void * mi_valloc(size_t size)
mi_pvalloc
void * mi_pvalloc(size_t size)
mi__expand
void * mi__expand(void *p, size_t newsize)
mi_wdupenv_s
int mi_wdupenv_s(unsigned short **buf, size_t *size, const unsigned short *name)
mi_cfree
void mi_cfree(void *p)
Just as free but also checks if the pointer p belongs to our heap.
mi_memalign
void * mi_memalign(size_t alignment, size_t size)
mi_free_size_aligned
void mi_free_size_aligned(void *p, size_t size, size_t alignment)
mi_mbsdup
unsigned char * mi_mbsdup(const unsigned char *s)
mi_reallocarr
int mi_reallocarr(void *p, size_t count, size_t size)
Corresponds to reallocarr in NetBSD.
mi_malloc_good_size
size_t mi_malloc_good_size(size_t size)
mi_wcsdup
unsigned short * mi_wcsdup(const unsigned short *s)
mi_dupenv_s
int mi_dupenv_s(char **buf, size_t *size, const char *name)
mi_posix_memalign
int mi_posix_memalign(void **p, size_t alignment, size_t size)
mi__posix_memalign
int mi__posix_memalign(void **p, size_t alignment, size_t size)
mi_reallocarray
void * mi_reallocarray(void *p, size_t count, size_t size)
Correspond s to reallocarray in FreeBSD.
mi_free_size
void mi_free_size(void *p, size_t size)
mi_aligned_recalloc
void * mi_aligned_recalloc(void *p, size_t newcount, size_t size, size_t alignment)
mi_stats_s::version
size_t version
initialize with `MI_STAT_VERSION (so linking dynamically with a separately compiled mimalloc is safe)
Definition mimalloc-doc.h:1057
mi_stats_s::size
size_t size
initialize with sizeof(mi_stats_t) (so linking dynamically with a separately compiled mimalloc is saf...
Definition mimalloc-doc.h:1055
mi_process_info_print_out
void mi_process_info_print_out(mi_output_fun *out, void *arg)
Print out all process info.
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.
mi_heap_stats_get
bool mi_heap_stats_get(mi_heap_t *heap, mi_stats_t *stats)
v3: Return statistics for a given heap.
mi_stats_print
void mi_stats_print(void *out)
Deprecated.
mi_stats_reset
void mi_stats_reset(void)
v1,v2: Reset statistics.
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.
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.
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.
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.
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.
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).
mi_stats_merge
void mi_stats_merge(void)
v1,v2: Merge thread local statistics with the main statistics and reset.
mi_stats_get
bool mi_stats_get(mi_stats_t *stats)
Get the statistics for the current subprocess aggregated over all its heaps.
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.
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.
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.
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_process_info_print
void mi_process_info_print(void)
Print out all process info.
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.
mi_stats_s
Statistics. See include/mimalloc-stats.h for the full definition.
Definition mimalloc-doc.h:1053
mi_subproc_main
mi_subproc_id_t mi_subproc_main(void)
Get the main sub-process identifier.
mi_heap_visit_fun
bool mi_heap_visit_fun(mi_heap_t *heap, void *arg)
The type of a heap visitor function.
Definition mimalloc-doc.h:863
mi_subproc_new
mi_subproc_id_t mi_subproc_new(void)
Create a fresh sub-process (with no associated threads yet).
mi_subproc_id_t
void * mi_subproc_id_t
A process can associate threads with sub-processes.
Definition mimalloc-doc.h:832
mi_subproc_delete
void mi_subproc_delete(mi_subproc_id_t subproc)
v1,v2: Delete a previously created sub-process.
mi_subproc_current
mi_subproc_id_t mi_subproc_current(void)
Get the current sub-process identifier of this thread.
mi_subproc_destroy
void mi_subproc_destroy(mi_subproc_id_t subproc)
v3: Destroy a previously created sub-process.
mi_subproc_add_current_thread
void mi_subproc_add_current_thread(mi_subproc_id_t subproc)
Add the current thread to the given sub-process.
mi_subproc_visit_heaps
bool mi_subproc_visit_heaps(mi_subproc_id_t subproc, mi_heap_visit_fun *visitor, void *arg)
Visit all heaps belonging to a subprocess.
mi_theap_set_default
mi_theap_t * mi_theap_set_default(mi_theap_t *theap)
Set the default thread-local theap to use in the current thread for mi_malloc() et al.
mi_theap_realloc
void * mi_theap_realloc(mi_theap_t *theap, void *p, size_t newsize)
mi_theap_malloc_small
void * mi_theap_malloc_small(mi_theap_t *theap, size_t size)
Allocate a small object in a specific theap. size must be smaller or equal to MI_SMALL_SIZE_MAX().
mi_theap_get_default
mi_theap_t * mi_theap_get_default()
Get the default theap that is used for mi_malloc() et al. for the current thread.
mi_heap_theap
mi_theap_t * mi_heap_theap(mi_heap_t *heap)
Return the thread-local theap for the given heap.
mi_theap_malloc_aligned
void * mi_theap_malloc_aligned(mi_theap_t *theap, size_t size, size_t alignment)
mi_theap_t
struct mi_theap_s mi_theap_t
Type of thread-local heaps.
Definition mimalloc-doc.h:1306
mi_theap_collect
void mi_theap_collect(mi_theap_t *theap, bool force)
Release outstanding resources in a specific theap.
mi_theap_zalloc
void * mi_theap_zalloc(mi_theap_t *theap, size_t size)
Allocate zero-initialized in a specific heap.
mi_theap_zalloc_small
void * mi_theap_zalloc_small(mi_theap_t *theap, size_t size)
Allocate a small object in a specific theap. size must be smaller or equal to MI_SMALL_SIZE_MAX().
mi_theap_malloc
void * mi_theap_malloc(mi_theap_t *theap, size_t size)
Allocate in a specific theap.
mi_theap_calloc
void * mi_theap_calloc(mi_theap_t *theap, size_t count, size_t size)
mi_heap_recalloc_aligned_at
void * mi_heap_recalloc_aligned_at(mi_heap_t *heap, void *p, size_t newcount, size_t size, size_t alignment, size_t offset)
mi_recalloc
void * mi_recalloc(void *p, size_t count, size_t size)
Re-allocate memory to count elements of size bytes, with extra memory initialized to zero.
mi_heap_rezalloc_aligned_at
void * mi_heap_rezalloc_aligned_at(mi_heap_t *heap, void *p, size_t newsize, size_t alignment, size_t offset)
mi_recalloc_aligned
void * mi_recalloc_aligned(void *p, size_t newcount, size_t size, size_t alignment)
mi_rezalloc_aligned
void * mi_rezalloc_aligned(void *p, size_t newsize, size_t alignment)
mi_heap_rezalloc_aligned
void * mi_heap_rezalloc_aligned(mi_heap_t *heap, void *p, size_t newsize, size_t alignment)
mi_rezalloc_aligned_at
void * mi_rezalloc_aligned_at(void *p, size_t newsize, size_t alignment, size_t offset)
mi_heap_recalloc_aligned
void * mi_heap_recalloc_aligned(mi_heap_t *heap, void *p, size_t newcount, size_t size, size_t alignment)
mi_heap_rezalloc
void * mi_heap_rezalloc(mi_heap_t *heap, void *p, size_t newsize)
mi_recalloc_aligned_at
void * mi_recalloc_aligned_at(void *p, size_t newcount, size_t size, size_t alignment, size_t offset)
mi_heap_recalloc
void * mi_heap_recalloc(mi_heap_t *heap, void *p, size_t newcount, size_t size)
mi_rezalloc
void * mi_rezalloc(void *p, size_t newsize)