mi-malloc: mimalloc-doc.h Source File

| mi-malloc 1.6 |

mimalloc-doc.h
1 /* ----------------------------------------------------------------------------
2 Copyright (c) 2018, Microsoft Research, Daan Leijen
3 This is free software; you can redistribute it and/or modify it under the
4 terms 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
91
95
99 void mi_free(void* p);
100
105 void* mi_malloc(size_t size);
106
111 void* mi_zalloc(size_t size);
112
122 void* mi_calloc(size_t count, size_t size);
123
136 void* mi_realloc(void* p, size_t newsize);
137
148 void* mi_recalloc(void* p, size_t count, size_t size);
149
163 void* mi_expand(void* p, size_t newsize);
164
174 void* mi_mallocn(size_t count, size_t size);
175
185 void* mi_reallocn(void* p, size_t count, size_t size);
186
203 void* mi_reallocf(void* p, size_t newsize);
204
205
214 char* mi_strdup(const char* s);
215
225 char* mi_strndup(const char* s, size_t n);
226
239 char* mi_realpath(const char* fname, char* resolved_name);
240
242
243 // ------------------------------------------------------
244 // Extended functionality
245 // ------------------------------------------------------
246
250
253 #define MI_SMALL_SIZE_MAX (128*sizeof(void*))
254
262 void* mi_malloc_small(size_t size);
263
271 void* mi_zalloc_small(size_t size);
272
287 size_t mi_usable_size(void* p);
288
298 size_t mi_good_size(size_t size);
299
307 void mi_collect(bool force);
308
313 void mi_stats_print(void* out);
314
320 void mi_stats_print_out(mi_output_fun* out, void* arg);
321
323 void mi_stats_reset(void);
324
326 void mi_stats_merge(void);
327
331 void mi_thread_init(void);
332
337 void mi_thread_done(void);
338
344 void mi_thread_stats_print_out(mi_output_fun* out, void* arg);
345
352 typedef void (mi_deferred_free_fun)(bool force, unsigned long long heartbeat, void* arg);
353
369 void mi_register_deferred_free(mi_deferred_free_fun* deferred_free, void* arg);
370
376 typedef void (mi_output_fun)(const char* msg, void* arg);
377
384 void mi_register_output(mi_output_fun* out, void* arg);
385
391 typedef void (mi_error_fun)(int err, void* arg);
392
408 void mi_register_error(mi_error_fun* errfun, void* arg);
409
414 bool mi_is_in_heap_region(const void* p);
415
416
429 int mi_reserve_huge_os_pages_interleave(size_t pages, size_t numa_nodes, size_t timeout_msecs);
430
443 int mi_reserve_huge_os_pages_at(size_t pages, int numa_node, size_t timeout_msecs);
444
445
450 bool mi_is_redirected();
451
465 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);
466
468
469 // ------------------------------------------------------
470 // Aligned allocation
471 // ------------------------------------------------------
472
478
491 void* mi_malloc_aligned(size_t size, size_t alignment);
492 void* mi_zalloc_aligned(size_t size, size_t alignment);
493 void* mi_calloc_aligned(size_t count, size_t size, size_t alignment);
494 void* mi_realloc_aligned(void* p, size_t newsize, size_t alignment);
495
506 void* mi_malloc_aligned_at(size_t size, size_t alignment, size_t offset);
507 void* mi_zalloc_aligned_at(size_t size, size_t alignment, size_t offset);
508 void* mi_calloc_aligned_at(size_t count, size_t size, size_t alignment, size_t offset);
509 void* mi_realloc_aligned_at(void* p, size_t newsize, size_t alignment, size_t offset);
510
512
518
523 struct mi_heap_s;
524
529 typedef struct mi_heap_s mi_heap_t;
530
532 mi_heap_t* mi_heap_new();
533
541 void mi_heap_delete(mi_heap_t* heap);
542
550 void mi_heap_destroy(mi_heap_t* heap);
551
555 mi_heap_t* mi_heap_set_default(mi_heap_t* heap);
556
559 mi_heap_t* mi_heap_get_default();
560
566 mi_heap_t* mi_heap_get_backing();
567
569 void mi_heap_collect(mi_heap_t* heap, bool force);
570
573 void* mi_heap_malloc(mi_heap_t* heap, size_t size);
574
578 void* mi_heap_malloc_small(mi_heap_t* heap, size_t size);
579
582 void* mi_heap_zalloc(mi_heap_t* heap, size_t size);
583
586 void* mi_heap_calloc(mi_heap_t* heap, size_t count, size_t size);
587
590 void* mi_heap_mallocn(mi_heap_t* heap, size_t count, size_t size);
591
594 char* mi_heap_strdup(mi_heap_t* heap, const char* s);
595
598 char* mi_heap_strndup(mi_heap_t* heap, const char* s, size_t n);
599
602 char* mi_heap_realpath(mi_heap_t* heap, const char* fname, char* resolved_name);
603
604 void* mi_heap_realloc(mi_heap_t* heap, void* p, size_t newsize);
605 void* mi_heap_reallocn(mi_heap_t* heap, void* p, size_t count, size_t size);
606 void* mi_heap_reallocf(mi_heap_t* heap, void* p, size_t newsize);
607
608 void* mi_heap_malloc_aligned(mi_heap_t* heap, size_t size, size_t alignment);
609 void* mi_heap_malloc_aligned_at(mi_heap_t* heap, size_t size, size_t alignment, size_t offset);
610 void* mi_heap_zalloc_aligned(mi_heap_t* heap, size_t size, size_t alignment);
611 void* mi_heap_zalloc_aligned_at(mi_heap_t* heap, size_t size, size_t alignment, size_t offset);
612 void* mi_heap_calloc_aligned(mi_heap_t* heap, size_t count, size_t size, size_t alignment);
613 void* mi_heap_calloc_aligned_at(mi_heap_t* heap, size_t count, size_t size, size_t alignment, size_t offset);
614 void* mi_heap_realloc_aligned(mi_heap_t* heap, void* p, size_t newsize, size_t alignment);
615 void* mi_heap_realloc_aligned_at(mi_heap_t* heap, void* p, size_t newsize, size_t alignment, size_t offset);
616
618
619
628
629 void* mi_rezalloc(void* p, size_t newsize);
630 void* mi_recalloc(void* p, size_t newcount, size_t size) ;
631
632 void* mi_rezalloc_aligned(void* p, size_t newsize, size_t alignment);
633 void* mi_rezalloc_aligned_at(void* p, size_t newsize, size_t alignment, size_t offset);
634 void* mi_recalloc_aligned(void* p, size_t newcount, size_t size, size_t alignment);
635 void* mi_recalloc_aligned_at(void* p, size_t newcount, size_t size, size_t alignment, size_t offset);
636
637 void* mi_heap_rezalloc(mi_heap_t* heap, void* p, size_t newsize);
638 void* mi_heap_recalloc(mi_heap_t* heap, void* p, size_t newcount, size_t size);
639
640 void* mi_heap_rezalloc_aligned(mi_heap_t* heap, void* p, size_t newsize, size_t alignment);
641 void* mi_heap_rezalloc_aligned_at(mi_heap_t* heap, void* p, size_t newsize, size_t alignment, size_t offset);
642 void* mi_heap_recalloc_aligned(mi_heap_t* heap, void* p, size_t newcount, size_t size, size_t alignment);
643 void* mi_heap_recalloc_aligned_at(mi_heap_t* heap, void* p, size_t newcount, size_t size, size_t alignment, size_t offset);
644
646
655
667 #define mi_malloc_tp(tp) ((tp*)mi_malloc(sizeof(tp)))
668
670 #define mi_zalloc_tp(tp) ((tp*)mi_zalloc(sizeof(tp)))
671
673 #define mi_calloc_tp(tp,count) ((tp*)mi_calloc(count,sizeof(tp)))
674
676 #define mi_mallocn_tp(tp,count) ((tp*)mi_mallocn(count,sizeof(tp)))
677
679 #define mi_reallocn_tp(p,tp,count) ((tp*)mi_reallocn(p,count,sizeof(tp)))
680
682 #define mi_heap_malloc_tp(hp,tp) ((tp*)mi_heap_malloc(hp,sizeof(tp)))
683
685 #define mi_heap_zalloc_tp(hp,tp) ((tp*)mi_heap_zalloc(hp,sizeof(tp)))
686
688 #define mi_heap_calloc_tp(hp,tp,count) ((tp*)mi_heap_calloc(hp,count,sizeof(tp)))
689
691 #define mi_heap_mallocn_tp(hp,tp,count) ((tp*)mi_heap_mallocn(hp,count,sizeof(tp)))
692
694 #define mi_heap_reallocn_tp(hp,p,tp,count) ((tp*)mi_heap_reallocn(p,count,sizeof(tp)))
695
697 #define mi_heap_recalloc_tp(hp,p,tp,count) ((tp*)mi_heap_recalloc(p,count,sizeof(tp)))
698
700
706
713 bool mi_heap_contains_block(mi_heap_t* heap, const void* p);
714
723 bool mi_heap_check_owned(mi_heap_t* heap, const void* p);
724
732 bool mi_check_owned(const void* p);
733
736 typedef struct mi_heap_area_s {
737 void* blocks;
738 size_t reserved;
739 size_t committed;
740 size_t used;
741 size_t block_size;
742 } mi_heap_area_t;
743
751 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);
752
764 bool mi_heap_visit_blocks(const mi_heap_t* heap, bool visit_all_blocks, mi_block_visit_fun* visitor, void* arg);
765
767
773
775 typedef enum mi_option_e {
776 // stable options
777 mi_option_show_errors,
778 mi_option_show_stats,
779 mi_option_verbose,
780 // the following options are experimental
781 mi_option_eager_commit,
782 mi_option_eager_region_commit,
783 mi_option_large_os_pages,
784 mi_option_reserve_huge_os_pages,
785 mi_option_segment_cache,
786 mi_option_page_reset,
787 mi_option_segment_reset,
788 mi_option_reset_delay,
789 mi_option_use_numa_nodes,
790 mi_option_reset_decommits,
791 mi_option_eager_commit_delay,
792 mi_option_os_tag,
793 _mi_option_last
794 } mi_option_t;
795
796
797 bool mi_option_is_enabled(mi_option_t option);
798 void mi_option_enable(mi_option_t option);
799 void mi_option_disable(mi_option_t option);
800 void mi_option_set_enabled(mi_option_t option, bool enable);
801 void mi_option_set_enabled_default(mi_option_t option, bool enable);
802
803 long mi_option_get(mi_option_t option);
804 void mi_option_set(mi_option_t option, long value);
805 void mi_option_set_default(mi_option_t option, long value);
806
807
809
816
817 void* mi_recalloc(void* p, size_t count, size_t size);
818 size_t mi_malloc_size(const void* p);
819 size_t mi_malloc_usable_size(const void *p);
820
822 void mi_cfree(void* p);
823
824 int mi_posix_memalign(void** p, size_t alignment, size_t size);
825 int mi__posix_memalign(void** p, size_t alignment, size_t size);
826 void* mi_memalign(size_t alignment, size_t size);
827 void* mi_valloc(size_t size);
828
829 void* mi_pvalloc(size_t size);
830 void* mi_aligned_alloc(size_t alignment, size_t size);
831 void* mi_reallocarray(void* p, size_t count, size_t size);
832
833 void mi_free_size(void* p, size_t size);
834 void mi_free_size_aligned(void* p, size_t size, size_t alignment);
835 void mi_free_aligned(void* p, size_t alignment);
836
838
851
853 void* mi_new(std::size_t n) noexcept(false);
854
856 void* mi_new_n(size_t count, size_t size) noexcept(false);
857
859 void* mi_new_aligned(std::size_t n, std::align_val_t alignment) noexcept(false);
860
862 void* mi_new_nothrow(size_t n);
863
865 void* mi_new_aligned_nothrow(size_t n, size_t alignment);
866
868 void* mi_new_realloc(void* p, size_t newsize);
869
871 void* mi_new_reallocn(void* p, size_t newcount, size_t size);
872
880 template<class T> struct mi_stl_allocator { }
881
883
mi_usable_size
size_t mi_usable_size(void *p)
Return the available bytes in a memory block.
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_reallocn
void * mi_reallocn(void *p, size_t count, size_t size)
Re-allocate memory to count elements of size bytes.
mi_malloc_aligned
void * mi_malloc_aligned(size_t size, size_t alignment)
Allocate size bytes aligned by alignment.
mi_recalloc_aligned_at
void * mi_recalloc_aligned_at(void *p, size_t newcount, size_t size, size_t alignment, size_t offset)
mi_stats_reset
void mi_stats_reset(void)
Reset statistics.
mi_heap_realloc_aligned
void * mi_heap_realloc_aligned(mi_heap_t *heap, void *p, size_t newsize, size_t alignment)
mi_option_is_enabled
bool mi_option_is_enabled(mi_option_t option)
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_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_mallocn
void * mi_mallocn(size_t count, size_t size)
Allocate count elements of size bytes.
mi_malloc_size
size_t mi_malloc_size(const void *p)
mi_option_set_enabled
void mi_option_set_enabled(mi_option_t option, bool enable)
mi_posix_memalign
int mi_posix_memalign(void **p, size_t alignment, size_t size)
mi_stats_merge
void mi_stats_merge(void)
Merge thread local statistics with the main statistics and reset.
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_option_set_default
void mi_option_set_default(mi_option_t option, long value)
mi_stats_print_out
void mi_stats_print_out(mi_output_fun *out, void *arg)
Print the main statistics.
mi_error_fun
void() mi_error_fun(int err, void *arg)
Type of error callback functions.
Definition: mimalloc-doc.h:391
mi_rezalloc
void * mi_rezalloc(void *p, size_t newsize)
mi_option_eager_commit
Eagerly commit segments (4MiB) (enabled by default).
Definition: mimalloc-doc.h:781
mi_heap_zalloc
void * mi_heap_zalloc(mi_heap_t *heap, size_t size)
Allocate zero-initialized in a specific heap.
mi_option_set
void mi_option_set(mi_option_t option, long value)
mi_option_eager_region_commit
Eagerly commit large (256MiB) memory regions (enabled by default, except on Windows)
Definition: mimalloc-doc.h:782
mi_cfree
void mi_cfree(void *p)
Just as free but also checks if the pointer p belongs to our heap.
mi_recalloc_aligned
void * mi_recalloc_aligned(void *p, size_t newcount, size_t size, size_t alignment)
_mi_option_last
Definition: mimalloc-doc.h:793
mi_realloc_aligned_at
void * mi_realloc_aligned_at(void *p, size_t newsize, size_t alignment, size_t offset)
mi_heap_area_t::blocks
void * blocks
start of the area containing heap blocks
Definition: mimalloc-doc.h:737
mi_realloc_aligned
void * mi_realloc_aligned(void *p, size_t newsize, size_t alignment)
mi_option_enable
void mi_option_enable(mi_option_t option)
mi__posix_memalign
int mi__posix_memalign(void **p, size_t alignment, size_t size)
mi_free
void mi_free(void *p)
Free previously allocated memory.
mi_heap_strdup
char * mi_heap_strdup(mi_heap_t *heap, const char *s)
Duplicate a string in a specific heap.
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_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_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_calloc_aligned
void * mi_calloc_aligned(size_t count, size_t size, size_t alignment)
mi_heap_zalloc_aligned
void * mi_heap_zalloc_aligned(mi_heap_t *heap, size_t size, size_t alignment)
mi_zalloc_small
void * mi_zalloc_small(size_t size)
Allocate a zero initialized small object.
mi_strndup
char * mi_strndup(const char *s, size_t n)
Allocate and duplicate a string up to n bytes.
mi_expand
void * mi_expand(void *p, size_t newsize)
Try to re-allocate memory to newsize bytes in place.
mi_pvalloc
void * mi_pvalloc(size_t size)
mi_option_set_enabled_default
void mi_option_set_enabled_default(mi_option_t option, bool enable)
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_zalloc
void * mi_zalloc(size_t size)
Allocate zero-initialized size bytes.
mi_heap_rezalloc
void * mi_heap_rezalloc(mi_heap_t *heap, void *p, size_t newsize)
mi_option_segment_cache
The number of segments per thread to keep cached.
Definition: mimalloc-doc.h:785
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_calloc_aligned
void * mi_heap_calloc_aligned(mi_heap_t *heap, size_t count, size_t size, size_t alignment)
mi_is_redirected
bool mi_is_redirected()
Is the C runtime malloc API redirected?
mi_heap_area_t::block_size
size_t block_size
size in bytes of one block
Definition: mimalloc-doc.h:741
mi_reallocarray
void * mi_reallocarray(void *p, size_t count, size_t size)
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_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:352
mi_is_in_heap_region
bool mi_is_in_heap_region(const void *p)
Is a pointer part of our heap?
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_realloc
void * mi_realloc(void *p, size_t newsize)
Re-allocate memory to newsize bytes.
mi_option_reserve_huge_os_pages
The number of huge OS pages (1GiB in size) to reserve at the start of the program.
Definition: mimalloc-doc.h:784
mi_heap_reallocf
void * mi_heap_reallocf(mi_heap_t *heap, void *p, size_t newsize)
mi_free_size_aligned
void mi_free_size_aligned(void *p, size_t size, size_t alignment)
mi_rezalloc_aligned_at
void * mi_rezalloc_aligned_at(void *p, size_t newsize, size_t alignment, size_t offset)
mi_option_page_reset
Reset page memory after mi_option_reset_delay milliseconds when it becomes free.
Definition: mimalloc-doc.h:786
mi_thread_done
void mi_thread_done(void)
Uninitialize mimalloc on a thread.
mi_heap_visit_blocks
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.
mi_option_use_numa_nodes
Pretend there are at most N NUMA nodes.
Definition: mimalloc-doc.h:789
mi_malloc
void * mi_malloc(size_t size)
Allocate size bytes.
mi_register_error
void mi_register_error(mi_error_fun *errfun, void *arg)
Register an error callback function.
mi_option_reset_decommits
Experimental.
Definition: mimalloc-doc.h:790
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_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:751
mi_heap_recalloc
void * mi_heap_recalloc(mi_heap_t *heap, void *p, size_t newcount, size_t size)
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_realpath
char * mi_realpath(const char *fname, char *resolved_name)
Resolve a file path name.
mi_option_show_errors
Print error messages to stderr.
Definition: mimalloc-doc.h:777
mi_option_segment_reset
Experimental.
Definition: mimalloc-doc.h:787
mi_heap_rezalloc_aligned
void * mi_heap_rezalloc_aligned(mi_heap_t *heap, void *p, size_t newsize, size_t alignment)
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_memalign
void * mi_memalign(size_t alignment, size_t size)
mi_rezalloc_aligned
void * mi_rezalloc_aligned(void *p, size_t newsize, size_t alignment)
mi_heap_contains_block
bool mi_heap_contains_block(mi_heap_t *heap, const void *p)
Does a heap contain a pointer to a previously allocated block?
mi_heap_collect
void mi_heap_collect(mi_heap_t *heap, bool force)
Release outstanding resources in a specific heap.
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_option_verbose
Print verbose messages to stderr.
Definition: mimalloc-doc.h:779
mi_zalloc_aligned_at
void * mi_zalloc_aligned_at(size_t size, size_t alignment, size_t offset)
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_heap_delete
void mi_heap_delete(mi_heap_t *heap)
Delete a previously allocated heap.
mi_option_os_tag
OS tag to assign to mimalloc'd memory.
Definition: mimalloc-doc.h:792
mi_heap_get_default
mi_heap_t * mi_heap_get_default()
Get the default heap that is used for mi_malloc() et al.
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_option_disable
void mi_option_disable(mi_option_t option)
mi_aligned_alloc
void * mi_aligned_alloc(size_t alignment, size_t size)
mi_valloc
void * mi_valloc(size_t size)
mi_thread_init
void mi_thread_init(void)
Initialize mimalloc on a thread.
mi_good_size
size_t mi_good_size(size_t size)
Return the used allocation size.
mi_stats_print
void mi_stats_print(void *out)
Deprecated.
mi_option_eager_commit_delay
Experimental.
Definition: mimalloc-doc.h:791
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_mallocn
void * mi_heap_mallocn(mi_heap_t *heap, size_t count, size_t size)
Allocate count elements in a specific heap.
mi_heap_area_t
An area of heap space contains blocks of a single size.
Definition: mimalloc-doc.h:736
mi_thread_stats_print_out
void mi_thread_stats_print_out(mi_output_fun *out, void *arg)
Print out heap statistics for this thread.
mi_option_show_stats
Print statistics to stderr when the program is done.
Definition: mimalloc-doc.h:778
mi_zalloc_aligned
void * mi_zalloc_aligned(size_t size, size_t alignment)
mi_heap_area_t::reserved
size_t reserved
bytes reserved for this area
Definition: mimalloc-doc.h:738
mi_heap_t
struct mi_heap_s mi_heap_t
Type of first-class heaps.
Definition: mimalloc-doc.h:529
mi_heap_area_t::used
size_t used
bytes in use by allocated blocks
Definition: mimalloc-doc.h:740
mi_register_deferred_free
void mi_register_deferred_free(mi_deferred_free_fun *deferred_free, void *arg)
Register a deferred free function.
mi_free_size
void mi_free_size(void *p, size_t size)
mi_collect
void mi_collect(bool force)
Eagerly free memory.
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_heap_destroy
void mi_heap_destroy(mi_heap_t *heap)
Destroy a heap, freeing all its still allocated blocks.
mi_calloc_aligned_at
void * mi_calloc_aligned_at(size_t count, size_t size, size_t alignment, size_t offset)
mi_option_large_os_pages
Use large OS pages (2MiB in size) if possible.
Definition: mimalloc-doc.h:783
mi_heap_reallocn
void * mi_heap_reallocn(mi_heap_t *heap, void *p, size_t count, size_t size)
mi_register_output
void mi_register_output(mi_output_fun *out, void *arg)
Register an output function.
mi_stl_allocator
std::allocator implementation for mimalloc for use in STL containers.
Definition: mimalloc-doc.h:880
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_realloc
void * mi_heap_realloc(mi_heap_t *heap, void *p, size_t newsize)
mi_malloc_usable_size
size_t mi_malloc_usable_size(const void *p)
mi_output_fun
void() mi_output_fun(const char *msg, void *arg)
Type of output functions.
Definition: mimalloc-doc.h:376
mi_strdup
char * mi_strdup(const char *s)
Allocate and duplicate a string.
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_reallocf
void * mi_reallocf(void *p, size_t newsize)
Re-allocate memory to newsize bytes,.
mi_calloc
void * mi_calloc(size_t count, size_t size)
Allocate zero-initialized count elements of size bytes.
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_malloc_small
void * mi_malloc_small(size_t size)
Allocate a small object.
mi_check_owned
bool mi_check_owned(const void *p)
Check safely if any pointer is part of the default heap of this thread.
mi_heap_malloc_aligned
void * mi_heap_malloc_aligned(mi_heap_t *heap, size_t size, size_t alignment)
mi_option_get
long mi_option_get(mi_option_t option)
mi_heap_get_backing
mi_heap_t * mi_heap_get_backing()
Get the backing heap.
mi_free_aligned
void mi_free_aligned(void *p, size_t alignment)
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_option_reset_delay
Delay in milli-seconds before resetting a page (100ms by default)
Definition: mimalloc-doc.h:788
mi_heap_new
mi_heap_t * mi_heap_new()
Create a new heap that can be used for allocation.
mi_heap_malloc
void * mi_heap_malloc(mi_heap_t *heap, size_t size)
Allocate in a specific heap.
mi_heap_area_t::committed
size_t committed
current committed bytes of this area
Definition: mimalloc-doc.h:739
mi_option_t
mi_option_t
Runtime options.
Definition: mimalloc-doc.h:775
mi_heap_check_owned
bool mi_heap_check_owned(mi_heap_t *heap, const void *p)
Check safely if any pointer is part of a heap.
mi_heap_set_default
mi_heap_t * mi_heap_set_default(mi_heap_t *heap)
Set the default heap to use for mi_malloc() et al.