mi-malloc 1.8/2.1
 
Loading...
Searching...
No Matches
mimalloc-doc.h
1/* ----------------------------------------------------------------------------
2Copyright (c) 2018-2021, 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
97
98
102void mi_free(void* p);
103
108void* mi_malloc(size_t size);
109
114void* mi_zalloc(size_t size);
115
125void* mi_calloc(size_t count, size_t size);
126
139void* mi_realloc(void* p, size_t newsize);
140
151void* mi_recalloc(void* p, size_t count, size_t size);
152
166void* mi_expand(void* p, size_t newsize);
167
177void* mi_mallocn(size_t count, size_t size);
178
188void* mi_reallocn(void* p, size_t count, size_t size);
189
206void* mi_reallocf(void* p, size_t newsize);
207
208
217char* mi_strdup(const char* s);
218
228char* mi_strndup(const char* s, size_t n);
229
242char* mi_realpath(const char* fname, char* resolved_name);
243
245
246// ------------------------------------------------------
247// Extended functionality
248// ------------------------------------------------------
249
253
256#define MI_SMALL_SIZE_MAX (128*sizeof(void*))
257
265void* mi_malloc_small(size_t size);
266
274void* mi_zalloc_small(size_t size);
275
289size_t mi_usable_size(void* p);
290
300size_t mi_good_size(size_t size);
301
309void mi_collect(bool force);
310
315void mi_stats_print(void* out);
316
322void mi_stats_print_out(mi_output_fun* out, void* arg);
323
325void mi_stats_reset(void);
326
328void mi_stats_merge(void);
329
333void mi_thread_init(void);
334
339void mi_thread_done(void);
340
347
354typedef void (mi_deferred_free_fun)(bool force, unsigned long long heartbeat, void* arg);
355
371void mi_register_deferred_free(mi_deferred_free_fun* deferred_free, void* arg);
372
378typedef void (mi_output_fun)(const char* msg, void* arg);
379
386void mi_register_output(mi_output_fun* out, void* arg);
387
393typedef void (mi_error_fun)(int err, void* arg);
394
410void mi_register_error(mi_error_fun* errfun, void* arg);
411
416bool mi_is_in_heap_region(const void* p);
417
426int mi_reserve_os_memory(size_t size, bool commit, bool allow_large);
427
439bool mi_manage_os_memory(void* start, size_t size, bool is_committed, bool is_large, bool is_zero, int numa_node);
440
453int mi_reserve_huge_os_pages_interleave(size_t pages, size_t numa_nodes, size_t timeout_msecs);
454
467int mi_reserve_huge_os_pages_at(size_t pages, int numa_node, size_t timeout_msecs);
468
469
475
489void 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);
490
495void mi_debug_show_arenas(bool show_inuse, bool show_abandoned, bool show_purge);
496
499typedef int mi_arena_id_t;
500
505void* mi_arena_area(mi_arena_id_t arena_id, size_t* size);
506
514int 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);
515
523int mi_reserve_os_memory_ex(size_t size, bool commit, bool allow_large, bool exclusive, mi_arena_id_t* arena_id);
524
535bool 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);
536
541
552mi_heap_t* mi_heap_new_ex(int heap_tag, bool allow_destroy, mi_arena_id_t arena_id);
553
557typedef void* mi_subproc_id_t;
558
561
565
570
574
575
577
578// ------------------------------------------------------
579// Aligned allocation
580// ------------------------------------------------------
581
589
607void* mi_malloc_aligned(size_t size, size_t alignment);
608void* mi_zalloc_aligned(size_t size, size_t alignment);
609void* mi_calloc_aligned(size_t count, size_t size, size_t alignment);
610void* mi_realloc_aligned(void* p, size_t newsize, size_t alignment);
611
623void* mi_malloc_aligned_at(size_t size, size_t alignment, size_t offset);
624void* mi_zalloc_aligned_at(size_t size, size_t alignment, size_t offset);
625void* mi_calloc_aligned_at(size_t count, size_t size, size_t alignment, size_t offset);
626void* mi_realloc_aligned_at(void* p, size_t newsize, size_t alignment, size_t offset);
627
629
635
640struct mi_heap_s;
641
646typedef struct mi_heap_s mi_heap_t;
647
650
659
668
673
677
684
686void mi_heap_collect(mi_heap_t* heap, bool force);
687
690void* mi_heap_malloc(mi_heap_t* heap, size_t size);
691
695void* mi_heap_malloc_small(mi_heap_t* heap, size_t size);
696
699void* mi_heap_zalloc(mi_heap_t* heap, size_t size);
700
703void* mi_heap_calloc(mi_heap_t* heap, size_t count, size_t size);
704
707void* mi_heap_mallocn(mi_heap_t* heap, size_t count, size_t size);
708
711char* mi_heap_strdup(mi_heap_t* heap, const char* s);
712
715char* mi_heap_strndup(mi_heap_t* heap, const char* s, size_t n);
716
719char* mi_heap_realpath(mi_heap_t* heap, const char* fname, char* resolved_name);
720
721void* mi_heap_realloc(mi_heap_t* heap, void* p, size_t newsize);
722void* mi_heap_reallocn(mi_heap_t* heap, void* p, size_t count, size_t size);
723void* mi_heap_reallocf(mi_heap_t* heap, void* p, size_t newsize);
724
725void* mi_heap_malloc_aligned(mi_heap_t* heap, size_t size, size_t alignment);
726void* mi_heap_malloc_aligned_at(mi_heap_t* heap, size_t size, size_t alignment, size_t offset);
727void* mi_heap_zalloc_aligned(mi_heap_t* heap, size_t size, size_t alignment);
728void* mi_heap_zalloc_aligned_at(mi_heap_t* heap, size_t size, size_t alignment, size_t offset);
729void* mi_heap_calloc_aligned(mi_heap_t* heap, size_t count, size_t size, size_t alignment);
730void* mi_heap_calloc_aligned_at(mi_heap_t* heap, size_t count, size_t size, size_t alignment, size_t offset);
731void* mi_heap_realloc_aligned(mi_heap_t* heap, void* p, size_t newsize, size_t alignment);
732void* mi_heap_realloc_aligned_at(mi_heap_t* heap, void* p, size_t newsize, size_t alignment, size_t offset);
733
735
736
745
746void* mi_rezalloc(void* p, size_t newsize);
747void* mi_recalloc(void* p, size_t newcount, size_t size) ;
748
749void* mi_rezalloc_aligned(void* p, size_t newsize, size_t alignment);
750void* mi_rezalloc_aligned_at(void* p, size_t newsize, size_t alignment, size_t offset);
751void* mi_recalloc_aligned(void* p, size_t newcount, size_t size, size_t alignment);
752void* mi_recalloc_aligned_at(void* p, size_t newcount, size_t size, size_t alignment, size_t offset);
753
754void* mi_heap_rezalloc(mi_heap_t* heap, void* p, size_t newsize);
755void* mi_heap_recalloc(mi_heap_t* heap, void* p, size_t newcount, size_t size);
756
757void* mi_heap_rezalloc_aligned(mi_heap_t* heap, void* p, size_t newsize, size_t alignment);
758void* mi_heap_rezalloc_aligned_at(mi_heap_t* heap, void* p, size_t newsize, size_t alignment, size_t offset);
759void* mi_heap_recalloc_aligned(mi_heap_t* heap, void* p, size_t newcount, size_t size, size_t alignment);
760void* mi_heap_recalloc_aligned_at(mi_heap_t* heap, void* p, size_t newcount, size_t size, size_t alignment, size_t offset);
761
763
772
784#define mi_malloc_tp(tp) ((tp*)mi_malloc(sizeof(tp)))
785
787#define mi_zalloc_tp(tp) ((tp*)mi_zalloc(sizeof(tp)))
788
790#define mi_calloc_tp(tp,count) ((tp*)mi_calloc(count,sizeof(tp)))
791
793#define mi_mallocn_tp(tp,count) ((tp*)mi_mallocn(count,sizeof(tp)))
794
796#define mi_reallocn_tp(p,tp,count) ((tp*)mi_reallocn(p,count,sizeof(tp)))
797
799#define mi_heap_malloc_tp(hp,tp) ((tp*)mi_heap_malloc(hp,sizeof(tp)))
800
802#define mi_heap_zalloc_tp(hp,tp) ((tp*)mi_heap_zalloc(hp,sizeof(tp)))
803
805#define mi_heap_calloc_tp(hp,tp,count) ((tp*)mi_heap_calloc(hp,count,sizeof(tp)))
806
808#define mi_heap_mallocn_tp(hp,tp,count) ((tp*)mi_heap_mallocn(hp,count,sizeof(tp)))
809
811#define mi_heap_reallocn_tp(hp,p,tp,count) ((tp*)mi_heap_reallocn(p,count,sizeof(tp)))
812
814#define mi_heap_recalloc_tp(hp,p,tp,count) ((tp*)mi_heap_recalloc(p,count,sizeof(tp)))
815
817
823
830bool mi_heap_contains_block(mi_heap_t* heap, const void* p);
831
840bool mi_heap_check_owned(mi_heap_t* heap, const void* p);
841
849bool mi_check_owned(const void* p);
850
853typedef struct mi_heap_area_s {
854 void* blocks;
855 size_t reserved;
856 size_t committed;
857 size_t used;
858 size_t block_size;
862
870typedef bool (mi_block_visit_fun)(const mi_heap_t* heap, const mi_heap_area_t* area, void* block, size_t block_size, void* arg);
871
883bool mi_heap_visit_blocks(const mi_heap_t* heap, bool visit_all_blocks, mi_block_visit_fun* visitor, void* arg);
884
900bool mi_abandoned_visit_blocks(mi_subproc_id_t subproc_id, int heap_tag, bool visit_blocks, mi_block_visit_fun* visitor, void* arg);
901
903
909
948
949
953void mi_option_set_enabled(mi_option_t option, bool enable);
955
957long mi_option_get_clamp(mi_option_t option, long min, long max);
959
960void mi_option_set(mi_option_t option, long value);
961void mi_option_set_default(mi_option_t option, long value);
962
963
965
972
974void mi_cfree(void* p);
975void* mi__expand(void* p, size_t newsize);
976
977void* mi_recalloc(void* p, size_t count, size_t size);
978size_t mi_malloc_size(const void* p);
979size_t mi_malloc_good_size(size_t size);
980size_t mi_malloc_usable_size(const void *p);
981
982int mi_posix_memalign(void** p, size_t alignment, size_t size);
983int mi__posix_memalign(void** p, size_t alignment, size_t size);
984void* mi_memalign(size_t alignment, size_t size);
985void* mi_valloc(size_t size);
986void* mi_pvalloc(size_t size);
987void* mi_aligned_alloc(size_t alignment, size_t size);
988
989unsigned short* mi_wcsdup(const unsigned short* s);
990unsigned char* mi_mbsdup(const unsigned char* s);
991int mi_dupenv_s(char** buf, size_t* size, const char* name);
992int mi_wdupenv_s(unsigned short** buf, size_t* size, const unsigned short* name);
993
996void* mi_reallocarray(void* p, size_t count, size_t size);
997
999int mi_reallocarr(void* p, size_t count, size_t size);
1000
1001void* mi_aligned_recalloc(void* p, size_t newcount, size_t size, size_t alignment);
1002void* mi_aligned_offset_recalloc(void* p, size_t newcount, size_t size, size_t alignment, size_t offset);
1003
1004void mi_free_size(void* p, size_t size);
1005void mi_free_size_aligned(void* p, size_t size, size_t alignment);
1006void mi_free_aligned(void* p, size_t alignment);
1007
1009
1022
1024void* mi_new(std::size_t n) noexcept(false);
1025
1027void* mi_new_n(size_t count, size_t size) noexcept(false);
1028
1030void* mi_new_aligned(std::size_t n, std::align_val_t alignment) noexcept(false);
1031
1033void* mi_new_nothrow(size_t n);
1034
1036void* mi_new_aligned_nothrow(size_t n, size_t alignment);
1037
1039void* mi_new_realloc(void* p, size_t newsize);
1040
1042void* mi_new_reallocn(void* p, size_t newcount, size_t size);
1043
1051template<class T> struct mi_stl_allocator { }
1052
1054
void * mi_malloc_aligned_at(size_t size, size_t alignment, size_t offset)
Allocate size bytes aligned by alignment at a specified offset.
void * mi_calloc_aligned(size_t count, size_t size, size_t alignment)
void * mi_realloc_aligned(void *p, size_t newsize, size_t alignment)
void * mi_malloc_aligned(size_t size, size_t alignment)
Allocate size bytes aligned by alignment.
void * mi_zalloc_aligned_at(size_t size, size_t alignment, size_t offset)
void * mi_calloc_aligned_at(size_t count, size_t size, size_t alignment, size_t offset)
void * mi_zalloc_aligned(size_t size, size_t alignment)
void * mi_realloc_aligned_at(void *p, size_t newsize, size_t alignment, size_t offset)
int heap_tag
heap tag associated with this area (see mi_heap_new_ex)
Definition mimalloc-doc.h:860
size_t block_size
size in bytes of one block
Definition mimalloc-doc.h:858
size_t committed
current committed bytes of this area
Definition mimalloc-doc.h:856
size_t full_block_size
size in bytes of a full block including padding and metadata.
Definition mimalloc-doc.h:859
size_t used
bytes in use by allocated blocks
Definition mimalloc-doc.h:857
void * blocks
start of the area containing heap blocks
Definition mimalloc-doc.h:854
size_t reserved
bytes reserved for this area
Definition mimalloc-doc.h:855
bool mi_heap_check_owned(mi_heap_t *heap, const void *p)
Check safely if any pointer is part of a heap.
bool mi_check_owned(const void *p)
Check safely if any pointer is part of the default heap of this thread.
bool mi_abandoned_visit_blocks(mi_subproc_id_t subproc_id, int heap_tag, bool visit_blocks, mi_block_visit_fun *visitor, void *arg)
Visit all areas and blocks in abandoned heaps.
bool mi_heap_visit_blocks(const mi_heap_t *heap, bool visit_all_blocks, mi_block_visit_fun *visitor, void *arg)
Visit all areas and blocks in a heap.
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:870
bool mi_heap_contains_block(mi_heap_t *heap, const void *p)
Does a heap contain a pointer to a previously allocated block?
An area of heap space contains blocks of a single size.
Definition mimalloc-doc.h:853
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.
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...
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...
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...
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.
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...
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...
std::allocator implementation for mimalloc for use in STL containers.
Definition mimalloc-doc.h:1051
int mi_reserve_os_memory(size_t size, bool commit, bool allow_large)
Reserve OS memory for use by mimalloc.
size_t mi_usable_size(void *p)
Return the available bytes in a memory block.
void mi_thread_done(void)
Uninitialize mimalloc on a thread.
void mi_deferred_free_fun(bool force, unsigned long long heartbeat, void *arg)
Type of deferred free functions.
Definition mimalloc-doc.h:354
void mi_stats_print(void *out)
Deprecated.
mi_subproc_id_t mi_subproc_main(void)
Get the main sub-process identifier.
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...
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.
void mi_register_deferred_free(mi_deferred_free_fun *deferred_free, void *arg)
Register a deferred free function.
mi_heap_t * mi_heap_new_ex(int heap_tag, bool allow_destroy, mi_arena_id_t arena_id)
Create a new heap.
void mi_stats_reset(void)
Reset statistics.
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.
void mi_collect(bool force)
Eagerly free 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.
void * mi_zalloc_small(size_t size)
Allocate a zero initialized small object.
void mi_stats_print_out(mi_output_fun *out, void *arg)
Print the main statistics.
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.
bool mi_is_in_heap_region(const void *p)
Is a pointer part of our heap?
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 ...
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_malloc_small(size_t size)
Allocate a small object.
mi_subproc_id_t mi_subproc_new(void)
Create a fresh sub-process (with no associated threads yet).
void mi_error_fun(int err, void *arg)
Type of error callback functions.
Definition mimalloc-doc.h:393
void mi_stats_merge(void)
Merge thread local statistics with the main statistics and reset.
void * mi_subproc_id_t
A process can associate threads with sub-processes.
Definition mimalloc-doc.h:557
int mi_arena_id_t
Mimalloc uses large (virtual) memory areas, called "arena"s, from the OS to manage its memory.
Definition mimalloc-doc.h:499
void * mi_arena_area(mi_arena_id_t arena_id, size_t *size)
Return the size of an arena.
void mi_register_error(mi_error_fun *errfun, void *arg)
Register an error callback function.
void mi_subproc_delete(mi_subproc_id_t subproc)
Delete a previously created sub-process.
bool mi_is_redirected()
Is the C runtime malloc API redirected?
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.
void mi_thread_stats_print_out(mi_output_fun *out, void *arg)
Print out heap statistics for this thread.
size_t mi_good_size(size_t size)
Return the used allocation size.
void mi_debug_show_arenas(bool show_inuse, bool show_abandoned, bool show_purge)
Show all current arena's.
void mi_subproc_add_current_thread(mi_subproc_id_t subproc)
Add the current thread to the given sub-process.
void mi_output_fun(const char *msg, void *arg)
Type of output functions.
Definition mimalloc-doc.h:378
void mi_register_output(mi_output_fun *out, void *arg)
Register an output function.
void mi_thread_init(void)
Initialize mimalloc on a thread.
void * mi_heap_malloc_small(mi_heap_t *heap, size_t size)
Allocate a small object in a specific heap.
mi_heap_t * mi_heap_get_default()
Get the default heap that is used for mi_malloc() et al.
void mi_heap_delete(mi_heap_t *heap)
Delete a previously allocated heap.
void * mi_heap_malloc_aligned(mi_heap_t *heap, size_t size, size_t alignment)
mi_heap_t * mi_heap_set_default(mi_heap_t *heap)
Set the default heap to use in the current thread for mi_malloc() et al.
struct mi_heap_s mi_heap_t
Type of first-class heaps.
Definition mimalloc-doc.h:646
void * mi_heap_zalloc_aligned_at(mi_heap_t *heap, size_t size, size_t alignment, size_t offset)
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.
char * mi_heap_strdup(mi_heap_t *heap, const char *s)
Duplicate a string in a specific heap.
void * mi_heap_zalloc_aligned(mi_heap_t *heap, size_t size, size_t alignment)
void * mi_heap_realloc_aligned_at(mi_heap_t *heap, void *p, size_t newsize, size_t alignment, size_t offset)
void mi_heap_collect(mi_heap_t *heap, bool force)
Release outstanding resources in a specific heap.
void mi_heap_destroy(mi_heap_t *heap)
Destroy a heap, freeing all its still allocated blocks.
void * mi_heap_calloc_aligned_at(mi_heap_t *heap, size_t count, size_t size, size_t alignment, size_t offset)
mi_heap_t * mi_heap_new()
Create a new heap that can be used for allocation.
void * mi_heap_mallocn(mi_heap_t *heap, size_t count, size_t size)
Allocate count elements in a specific heap.
void * mi_heap_malloc(mi_heap_t *heap, size_t size)
Allocate in a specific heap.
void * mi_heap_zalloc(mi_heap_t *heap, size_t size)
Allocate zero-initialized in a specific heap.
void * mi_heap_calloc(mi_heap_t *heap, size_t count, size_t size)
Allocate count zero-initialized elements in a specific heap.
void * mi_heap_realloc(mi_heap_t *heap, void *p, size_t newsize)
mi_heap_t * mi_heap_get_backing()
Get the backing heap.
void * mi_heap_calloc_aligned(mi_heap_t *heap, size_t count, size_t size, size_t alignment)
void * mi_heap_reallocn(mi_heap_t *heap, void *p, size_t count, size_t size)
void * mi_heap_realloc_aligned(mi_heap_t *heap, void *p, size_t newsize, size_t alignment)
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.
void * mi_heap_reallocf(mi_heap_t *heap, void *p, size_t newsize)
void * mi_heap_malloc_aligned_at(mi_heap_t *heap, size_t size, size_t alignment, size_t offset)
void * mi_realloc(void *p, size_t newsize)
Re-allocate memory to newsize bytes.
void * mi_expand(void *p, size_t newsize)
Try to re-allocate memory to newsize bytes in place.
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.
char * mi_strdup(const char *s)
Allocate and duplicate a string.
char * mi_strndup(const char *s, size_t n)
Allocate and duplicate a string up to n bytes.
void * mi_reallocf(void *p, size_t newsize)
Re-allocate memory to newsize bytes,.
void * mi_mallocn(size_t count, size_t size)
Allocate count elements of size bytes.
void * mi_calloc(size_t count, size_t size)
Allocate zero-initialized count elements of size bytes.
void * mi_reallocn(void *p, size_t count, size_t size)
Re-allocate memory to count elements of size bytes.
char * mi_realpath(const char *fname, char *resolved_name)
Resolve a file path name.
void * mi_malloc(size_t size)
Allocate size bytes.
void * mi_zalloc(size_t size)
Allocate zero-initialized size bytes.
void mi_free(void *p)
Free previously allocated memory.
void mi_option_enable(mi_option_t option)
size_t mi_option_get_size(mi_option_t option)
bool mi_option_is_enabled(mi_option_t option)
void mi_option_set_enabled_default(mi_option_t option, bool enable)
long mi_option_get(mi_option_t option)
void mi_option_set_default(mi_option_t option, long value)
long mi_option_get_clamp(mi_option_t option, long min, long max)
void mi_option_set_enabled(mi_option_t option, bool enable)
void mi_option_disable(mi_option_t option)
void mi_option_set(mi_option_t option, long value)
mi_option_t
Runtime options.
Definition mimalloc-doc.h:911
@ mi_option_abandoned_reclaim_on_free
allow to reclaim an abandoned segment on a free (=1)
Definition mimalloc-doc.h:941
@ mi_option_purge_extend_delay
extend purge delay on each subsequent delay (=1)
Definition mimalloc-doc.h:942
@ mi_option_show_stats
Print statistics on termination.
Definition mimalloc-doc.h:914
@ mi_option_use_numa_nodes
0 = use all available numa nodes, otherwise use at most N nodes.
Definition mimalloc-doc.h:935
@ mi_option_abandoned_page_purge
immediately purge delayed purges on thread termination
Definition mimalloc-doc.h:933
@ mi_option_eager_commit_delay
the first N segments per thread are not eagerly committed (but per page in the segment on demand)
Definition mimalloc-doc.h:931
@ mi_option_eager_commit
eager commit segments? (after eager_commit_delay segments) (enabled by default).
Definition mimalloc-doc.h:930
@ mi_option_visit_abandoned
allow visiting heap blocks from abandoned threads (=0)
Definition mimalloc-doc.h:944
@ mi_option_os_tag
tag used for OS logging (macOS only for now) (=100)
Definition mimalloc-doc.h:926
@ _mi_option_last
Definition mimalloc-doc.h:946
@ 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:939
@ mi_option_verbose
Print verbose messages.
Definition mimalloc-doc.h:915
@ mi_option_allow_large_os_pages
allow large (2 or 4 MiB) OS pages, implies eager commit. If false, also disables THP for the process.
Definition mimalloc-doc.h:923
@ mi_option_arena_purge_mult
multiplier for purge_delay for the purging delay for arenas (=10)
Definition mimalloc-doc.h:940
@ 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:927
@ 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:924
@ mi_option_limit_os_alloc
If set to 1, do not use OS memory for allocation (but only pre-reserved arenas)
Definition mimalloc-doc.h:937
@ mi_option_reserve_huge_os_pages_at
Reserve N huge OS pages at a specific NUMA node N.
Definition mimalloc-doc.h:921
@ mi_option_max_segment_reclaim
max. percentage of the abandoned segments can be reclaimed per try (=10%)
Definition mimalloc-doc.h:938
@ 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:925
@ mi_option_reserve_huge_os_pages
reserve N huge OS pages (1GiB pages) at startup
Definition mimalloc-doc.h:920
@ mi_option_disallow_os_alloc
1 = do not use OS memory for allocation (but only programmatically reserved arenas)
Definition mimalloc-doc.h:936
@ 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:934
@ mi_option_disallow_arena_alloc
1 = do not use arena's for allocation (except if using specific arena id's)
Definition mimalloc-doc.h:943
@ mi_option_max_errors
issue at most N error messages
Definition mimalloc-doc.h:916
@ mi_option_max_warnings
issue at most N warning messages
Definition mimalloc-doc.h:917
@ mi_option_show_errors
Print error messages.
Definition mimalloc-doc.h:913
@ 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:922
@ mi_option_arena_eager_commit
eager commit arenas? Use 2 to enable just on overcommit systems (=2)
Definition mimalloc-doc.h:932
size_t mi_malloc_usable_size(const void *p)
void mi_free_aligned(void *p, size_t alignment)
void * mi_aligned_offset_recalloc(void *p, size_t newcount, size_t size, size_t alignment, size_t offset)
void * mi_aligned_alloc(size_t alignment, size_t size)
size_t mi_malloc_size(const void *p)
void * mi_valloc(size_t size)
void * mi_pvalloc(size_t size)
void * mi__expand(void *p, size_t newsize)
int mi_wdupenv_s(unsigned short **buf, size_t *size, const unsigned short *name)
void mi_cfree(void *p)
Just as free but also checks if the pointer p belongs to our heap.
void * mi_memalign(size_t alignment, size_t size)
void mi_free_size_aligned(void *p, size_t size, size_t alignment)
unsigned char * mi_mbsdup(const unsigned char *s)
int mi_reallocarr(void *p, size_t count, size_t size)
Corresponds to reallocarr in NetBSD.
size_t mi_malloc_good_size(size_t size)
unsigned short * mi_wcsdup(const unsigned short *s)
int mi_dupenv_s(char **buf, size_t *size, const char *name)
int mi_posix_memalign(void **p, size_t alignment, size_t size)
int mi__posix_memalign(void **p, size_t alignment, size_t size)
void * mi_reallocarray(void *p, size_t count, size_t size)
Correspond s to reallocarray in FreeBSD.
void mi_free_size(void *p, size_t size)
void * mi_aligned_recalloc(void *p, size_t newcount, size_t size, size_t alignment)
void * mi_heap_recalloc_aligned_at(mi_heap_t *heap, void *p, size_t newcount, size_t size, size_t alignment, size_t offset)
void * mi_heap_rezalloc_aligned_at(mi_heap_t *heap, void *p, size_t newsize, size_t alignment, size_t offset)
void * mi_recalloc_aligned(void *p, size_t newcount, size_t size, size_t alignment)
void * mi_rezalloc_aligned(void *p, size_t newsize, size_t alignment)
void * mi_heap_rezalloc_aligned(mi_heap_t *heap, void *p, size_t newsize, size_t alignment)
void * mi_rezalloc_aligned_at(void *p, size_t newsize, size_t alignment, size_t offset)
void * mi_heap_recalloc_aligned(mi_heap_t *heap, void *p, size_t newcount, size_t size, size_t alignment)
void * mi_heap_rezalloc(mi_heap_t *heap, void *p, size_t newsize)
void * mi_recalloc_aligned_at(void *p, size_t newcount, size_t size, size_t alignment, size_t offset)
void * mi_heap_recalloc(mi_heap_t *heap, void *p, size_t newcount, size_t size)
void * mi_rezalloc(void *p, size_t newsize)