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
290size_t mi_usable_size(void* p);
291
301size_t mi_good_size(size_t size);
302
310void mi_collect(bool force);
311
316void mi_stats_print(void* out);
317
323void mi_stats_print_out(mi_output_fun* out, void* arg);
324
326void mi_stats_reset(void);
327
329void mi_stats_merge(void);
330
334void mi_thread_init(void);
335
340void mi_thread_done(void);
341
348
355typedef void (mi_deferred_free_fun)(bool force, unsigned long long heartbeat, void* arg);
356
372void mi_register_deferred_free(mi_deferred_free_fun* deferred_free, void* arg);
373
379typedef void (mi_output_fun)(const char* msg, void* arg);
380
387void mi_register_output(mi_output_fun* out, void* arg);
388
394typedef void (mi_error_fun)(int err, void* arg);
395
411void mi_register_error(mi_error_fun* errfun, void* arg);
412
417bool mi_is_in_heap_region(const void* p);
418
427int mi_reserve_os_memory(size_t size, bool commit, bool allow_large);
428
440bool mi_manage_os_memory(void* start, size_t size, bool is_committed, bool is_large, bool is_zero, int numa_node);
441
454int mi_reserve_huge_os_pages_interleave(size_t pages, size_t numa_nodes, size_t timeout_msecs);
455
468int mi_reserve_huge_os_pages_at(size_t pages, int numa_node, size_t timeout_msecs);
469
470
476
490void 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);
491
496void mi_debug_show_arenas(bool show_inuse, bool show_abandoned, bool show_purge);
497
500typedef int mi_arena_id_t;
501
506void* mi_arena_area(mi_arena_id_t arena_id, size_t* size);
507
515int 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);
516
524int mi_reserve_os_memory_ex(size_t size, bool commit, bool allow_large, bool exclusive, mi_arena_id_t* arena_id);
525
536bool 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);
537
542
546typedef void* mi_subproc_id_t;
547
550
554
559
563
564
566
567// ------------------------------------------------------
568// Aligned allocation
569// ------------------------------------------------------
570
578
592void* mi_malloc_aligned(size_t size, size_t alignment);
593void* mi_zalloc_aligned(size_t size, size_t alignment);
594void* mi_calloc_aligned(size_t count, size_t size, size_t alignment);
595void* mi_realloc_aligned(void* p, size_t newsize, size_t alignment);
596
607void* mi_malloc_aligned_at(size_t size, size_t alignment, size_t offset);
608void* mi_zalloc_aligned_at(size_t size, size_t alignment, size_t offset);
609void* mi_calloc_aligned_at(size_t count, size_t size, size_t alignment, size_t offset);
610void* mi_realloc_aligned_at(void* p, size_t newsize, size_t alignment, size_t offset);
611
613
619
624struct mi_heap_s;
625
630typedef struct mi_heap_s mi_heap_t;
631
634
643
652
657
661
668
670void mi_heap_collect(mi_heap_t* heap, bool force);
671
674void* mi_heap_malloc(mi_heap_t* heap, size_t size);
675
679void* mi_heap_malloc_small(mi_heap_t* heap, size_t size);
680
683void* mi_heap_zalloc(mi_heap_t* heap, size_t size);
684
687void* mi_heap_calloc(mi_heap_t* heap, size_t count, size_t size);
688
691void* mi_heap_mallocn(mi_heap_t* heap, size_t count, size_t size);
692
695char* mi_heap_strdup(mi_heap_t* heap, const char* s);
696
699char* mi_heap_strndup(mi_heap_t* heap, const char* s, size_t n);
700
703char* mi_heap_realpath(mi_heap_t* heap, const char* fname, char* resolved_name);
704
705void* mi_heap_realloc(mi_heap_t* heap, void* p, size_t newsize);
706void* mi_heap_reallocn(mi_heap_t* heap, void* p, size_t count, size_t size);
707void* mi_heap_reallocf(mi_heap_t* heap, void* p, size_t newsize);
708
709void* mi_heap_malloc_aligned(mi_heap_t* heap, size_t size, size_t alignment);
710void* mi_heap_malloc_aligned_at(mi_heap_t* heap, size_t size, size_t alignment, size_t offset);
711void* mi_heap_zalloc_aligned(mi_heap_t* heap, size_t size, size_t alignment);
712void* mi_heap_zalloc_aligned_at(mi_heap_t* heap, size_t size, size_t alignment, size_t offset);
713void* mi_heap_calloc_aligned(mi_heap_t* heap, size_t count, size_t size, size_t alignment);
714void* mi_heap_calloc_aligned_at(mi_heap_t* heap, size_t count, size_t size, size_t alignment, size_t offset);
715void* mi_heap_realloc_aligned(mi_heap_t* heap, void* p, size_t newsize, size_t alignment);
716void* mi_heap_realloc_aligned_at(mi_heap_t* heap, void* p, size_t newsize, size_t alignment, size_t offset);
717
719
720
729
730void* mi_rezalloc(void* p, size_t newsize);
731void* mi_recalloc(void* p, size_t newcount, size_t size) ;
732
733void* mi_rezalloc_aligned(void* p, size_t newsize, size_t alignment);
734void* mi_rezalloc_aligned_at(void* p, size_t newsize, size_t alignment, size_t offset);
735void* mi_recalloc_aligned(void* p, size_t newcount, size_t size, size_t alignment);
736void* mi_recalloc_aligned_at(void* p, size_t newcount, size_t size, size_t alignment, size_t offset);
737
738void* mi_heap_rezalloc(mi_heap_t* heap, void* p, size_t newsize);
739void* mi_heap_recalloc(mi_heap_t* heap, void* p, size_t newcount, size_t size);
740
741void* mi_heap_rezalloc_aligned(mi_heap_t* heap, void* p, size_t newsize, size_t alignment);
742void* mi_heap_rezalloc_aligned_at(mi_heap_t* heap, void* p, size_t newsize, size_t alignment, size_t offset);
743void* mi_heap_recalloc_aligned(mi_heap_t* heap, void* p, size_t newcount, size_t size, size_t alignment);
744void* mi_heap_recalloc_aligned_at(mi_heap_t* heap, void* p, size_t newcount, size_t size, size_t alignment, size_t offset);
745
747
756
768#define mi_malloc_tp(tp) ((tp*)mi_malloc(sizeof(tp)))
769
771#define mi_zalloc_tp(tp) ((tp*)mi_zalloc(sizeof(tp)))
772
774#define mi_calloc_tp(tp,count) ((tp*)mi_calloc(count,sizeof(tp)))
775
777#define mi_mallocn_tp(tp,count) ((tp*)mi_mallocn(count,sizeof(tp)))
778
780#define mi_reallocn_tp(p,tp,count) ((tp*)mi_reallocn(p,count,sizeof(tp)))
781
783#define mi_heap_malloc_tp(hp,tp) ((tp*)mi_heap_malloc(hp,sizeof(tp)))
784
786#define mi_heap_zalloc_tp(hp,tp) ((tp*)mi_heap_zalloc(hp,sizeof(tp)))
787
789#define mi_heap_calloc_tp(hp,tp,count) ((tp*)mi_heap_calloc(hp,count,sizeof(tp)))
790
792#define mi_heap_mallocn_tp(hp,tp,count) ((tp*)mi_heap_mallocn(hp,count,sizeof(tp)))
793
795#define mi_heap_reallocn_tp(hp,p,tp,count) ((tp*)mi_heap_reallocn(p,count,sizeof(tp)))
796
798#define mi_heap_recalloc_tp(hp,p,tp,count) ((tp*)mi_heap_recalloc(p,count,sizeof(tp)))
799
801
807
814bool mi_heap_contains_block(mi_heap_t* heap, const void* p);
815
824bool mi_heap_check_owned(mi_heap_t* heap, const void* p);
825
833bool mi_check_owned(const void* p);
834
837typedef struct mi_heap_area_s {
838 void* blocks;
839 size_t reserved;
840 size_t committed;
841 size_t used;
842 size_t block_size;
845
853typedef bool (mi_block_visit_fun)(const mi_heap_t* heap, const mi_heap_area_t* area, void* block, size_t block_size, void* arg);
854
866bool mi_heap_visit_blocks(const mi_heap_t* heap, bool visit_all_blocks, mi_block_visit_fun* visitor, void* arg);
867
871bool mi_abandoned_visit_blocks(mi_subproc_id_t subproc_id, int heap_tag, bool visit_blocks, mi_block_visit_fun* visitor, void* arg);
872
874
880
919
920
924void mi_option_set_enabled(mi_option_t option, bool enable);
926
928long mi_option_get_clamp(mi_option_t option, long min, long max);
930
931void mi_option_set(mi_option_t option, long value);
932void mi_option_set_default(mi_option_t option, long value);
933
934
936
943
945void mi_cfree(void* p);
946void* mi__expand(void* p, size_t newsize);
947
948void* mi_recalloc(void* p, size_t count, size_t size);
949size_t mi_malloc_size(const void* p);
950size_t mi_malloc_good_size(size_t size);
951size_t mi_malloc_usable_size(const void *p);
952
953int mi_posix_memalign(void** p, size_t alignment, size_t size);
954int mi__posix_memalign(void** p, size_t alignment, size_t size);
955void* mi_memalign(size_t alignment, size_t size);
956void* mi_valloc(size_t size);
957void* mi_pvalloc(size_t size);
958void* mi_aligned_alloc(size_t alignment, size_t size);
959
960unsigned short* mi_wcsdup(const unsigned short* s);
961unsigned char* mi_mbsdup(const unsigned char* s);
962int mi_dupenv_s(char** buf, size_t* size, const char* name);
963int mi_wdupenv_s(unsigned short** buf, size_t* size, const unsigned short* name);
964
967void* mi_reallocarray(void* p, size_t count, size_t size);
968
970int mi_reallocarr(void* p, size_t count, size_t size);
971
972void* mi_aligned_recalloc(void* p, size_t newcount, size_t size, size_t alignment);
973void* mi_aligned_offset_recalloc(void* p, size_t newcount, size_t size, size_t alignment, size_t offset);
974
975void mi_free_size(void* p, size_t size);
976void mi_free_size_aligned(void* p, size_t size, size_t alignment);
977void mi_free_aligned(void* p, size_t alignment);
978
980
993
995void* mi_new(std::size_t n) noexcept(false);
996
998void* mi_new_n(size_t count, size_t size) noexcept(false);
999
1001void* mi_new_aligned(std::size_t n, std::align_val_t alignment) noexcept(false);
1002
1004void* mi_new_nothrow(size_t n);
1005
1007void* mi_new_aligned_nothrow(size_t n, size_t alignment);
1008
1010void* mi_new_realloc(void* p, size_t newsize);
1011
1013void* mi_new_reallocn(void* p, size_t newcount, size_t size);
1014
1022template<class T> struct mi_stl_allocator { }
1023
1025
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)
size_t block_size
size in bytes of one block
Definition mimalloc-doc.h:842
size_t committed
current committed bytes of this area
Definition mimalloc-doc.h:840
size_t full_block_size
size in bytes of a full block including padding and metadata.
Definition mimalloc-doc.h:843
size_t used
bytes in use by allocated blocks
Definition mimalloc-doc.h:841
void * blocks
start of the area containing heap blocks
Definition mimalloc-doc.h:838
size_t reserved
bytes reserved for this area
Definition mimalloc-doc.h:839
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:853
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:837
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:1022
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:355
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.
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:394
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:546
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:500
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:379
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:630
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:882
@ mi_option_abandoned_reclaim_on_free
allow to reclaim an abandoned segment on a free (=1)
Definition mimalloc-doc.h:912
@ mi_option_purge_extend_delay
extend purge delay on each subsequent delay (=1)
Definition mimalloc-doc.h:913
@ mi_option_show_stats
Print statistics on termination.
Definition mimalloc-doc.h:885
@ mi_option_use_numa_nodes
0 = use all available numa nodes, otherwise use at most N nodes.
Definition mimalloc-doc.h:906
@ mi_option_abandoned_page_purge
immediately purge delayed purges on thread termination
Definition mimalloc-doc.h:904
@ 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:902
@ mi_option_eager_commit
eager commit segments? (after eager_commit_delay segments) (enabled by default).
Definition mimalloc-doc.h:901
@ mi_option_visit_abandoned
allow visiting heap blocks from abandoned threads (=0)
Definition mimalloc-doc.h:915
@ mi_option_os_tag
tag used for OS logging (macOS only for now) (=100)
Definition mimalloc-doc.h:897
@ _mi_option_last
Definition mimalloc-doc.h:917
@ 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:910
@ mi_option_verbose
Print verbose messages.
Definition mimalloc-doc.h:886
@ 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:894
@ mi_option_arena_purge_mult
multiplier for purge_delay for the purging delay for arenas (=10)
Definition mimalloc-doc.h:911
@ 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:898
@ 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:895
@ 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:908
@ mi_option_reserve_huge_os_pages_at
Reserve N huge OS pages at a specific NUMA node N.
Definition mimalloc-doc.h:892
@ mi_option_max_segment_reclaim
max. percentage of the abandoned segments can be reclaimed per try (=10%)
Definition mimalloc-doc.h:909
@ 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:896
@ mi_option_reserve_huge_os_pages
reserve N huge OS pages (1GiB pages) at startup
Definition mimalloc-doc.h:891
@ mi_option_disallow_os_alloc
1 = do not use OS memory for allocation (but only programmatically reserved arenas)
Definition mimalloc-doc.h:907
@ 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:905
@ mi_option_disallow_arena_alloc
1 = do not use arena's for allocation (except if using specific arena id's)
Definition mimalloc-doc.h:914
@ mi_option_max_errors
issue at most N error messages
Definition mimalloc-doc.h:887
@ mi_option_max_warnings
issue at most N warning messages
Definition mimalloc-doc.h:888
@ mi_option_show_errors
Print error messages.
Definition mimalloc-doc.h:884
@ 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:893
@ mi_option_arena_eager_commit
eager commit arenas? Use 2 to enable just on overcommit systems (=2)
Definition mimalloc-doc.h:903
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)