diff --git a/doc/mimalloc-doc.h b/doc/mimalloc-doc.h index c9cb580d..7c238d29 100644 --- a/doc/mimalloc-doc.h +++ b/doc/mimalloc-doc.h @@ -26,17 +26,25 @@ without code changes, for example, on Unix you can use it as: Notable aspects of the design include: -- __small and consistent__: the library is less than 6k LOC using simple and +- __small and consistent__: the library is about 8k LOC using simple and consistent data structures. This makes it very suitable to integrate and adapt in other projects. For runtime systems it provides hooks for a monotonic _heartbeat_ and deferred freeing (for bounded worst-case times with reference counting). -- __free list sharding__: the big idea: instead of one big free list (per size class) we have - many smaller lists per memory "page" which both reduces fragmentation - and increases locality -- +- __free list sharding__: instead of one big free list (per size class) we have + many smaller lists per "mimalloc page" which reduces fragmentation and + increases locality -- things that are allocated close in time get allocated close in memory. - (A memory "page" in _mimalloc_ contains blocks of one size class and is - usually 64KiB on a 64-bit system). + (A mimalloc page contains blocks of one size class and is usually 64KiB on a 64-bit system). +- __free list multi-sharding__: the big idea! Not only do we shard the free list + per mimalloc page, but for each page we have multiple free lists. In particular, there + is one list for thread-local `free` operations, and another one for concurrent `free` + operations. Free-ing from another thread can now be a single CAS without needing + sophisticated coordination between threads. Since there will be + thousands of separate free lists, contention is naturally distributed over the heap, + and the chance of contending on a single location will be low -- this is quite + similar to randomized algorithms like skip lists where adding + a random oracle removes the need for a more complex algorithm. - __eager page reset__: when a "page" becomes empty (with increased chance due to free list sharding) the memory is marked to the OS as unused ("reset" or "purged") reducing (real) memory pressure and fragmentation, especially in long running @@ -51,7 +59,7 @@ Notable aspects of the design include: times (_wcat_), bounded space overhead (~0.2% meta-data, with at most 12.5% waste in allocation sizes), and has no internal points of contention using only atomic operations. - __fast__: In our benchmarks (see [below](#performance)), - _mimalloc_ always outperforms all other leading allocators (_jemalloc_, _tcmalloc_, _Hoard_, etc), + _mimalloc_ outperforms all other leading allocators (_jemalloc_, _tcmalloc_, _Hoard_, etc), and usually uses less memory (up to 25% more in the worst case). A nice property is that it does consistently well over a wide range of benchmarks. @@ -442,7 +450,8 @@ int mi_reserve_huge_os_pages_at(size_t pages, int numa_node, size_t timeout_msec bool mi_is_redirected(); /// Return process information (time and memory usage). -/// @param user_msecs Optional. User time in milli-seconds. +/// @param elapsed_msecs Optional. Elapsed wall-clock time of the process in milli-seconds. +/// @param user_msecs Optional. User time in milli-seconds (as the sum over all threads). /// @param system_msecs Optional. System time in milli-seconds. /// @param current_rss Optional. Current working set size (touched pages). /// @param peak_rss Optional. Peak working set size (touched pages). @@ -453,7 +462,7 @@ bool mi_is_redirected(); /// The \a current_rss is precise on Windows and MacOSX; other systems estimate /// this using \a current_commit. The \a commit is precise on Windows but estimated /// on other systems as the amount of read/write accessible memory reserved by mimalloc. -void mi_process_info(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); +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); /// \} diff --git a/docs/group__extended.html b/docs/group__extended.html index c9145660..12e51cbb 100644 --- a/docs/group__extended.html +++ b/docs/group__extended.html @@ -187,9 +187,9 @@ Functions bool mi_is_redirected ()  Is the C runtime malloc API redirected? More...
  -void mi_process_info (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). More...
-  +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). More...

Detailed Description

Extended functionality.

@@ -416,8 +416,8 @@ Functions - -

◆ mi_process_info()

+ +

◆ mi_process_info()

@@ -426,6 +426,12 @@ Functions void mi_process_info ( size_t *  + elapsed_msecs, + + + + + size_t *  user_msecs, @@ -475,7 +481,8 @@ Functions

Return process information (time and memory usage).

Parameters
- + + diff --git a/docs/group__extended.js b/docs/group__extended.js index 7f298b16..ed4a8b46 100644 --- a/docs/group__extended.js +++ b/docs/group__extended.js @@ -9,7 +9,7 @@ var group__extended = [ "mi_is_in_heap_region", "group__extended.html#ga5f071b10d4df1c3658e04e7fd67a94e6", null ], [ "mi_is_redirected", "group__extended.html#gaad25050b19f30cd79397b227e0157a3f", null ], [ "mi_malloc_small", "group__extended.html#ga7136c2e55cb22c98ecf95d08d6debb99", null ], - [ "mi_process_info", "group__extended.html#ga9144506d5ffa8cc03547867bd15e1032", null ], + [ "mi_process_info", "group__extended.html#ga7d862c2affd5790381da14eb102a364d", null ], [ "mi_register_deferred_free", "group__extended.html#ga3460a6ca91af97be4058f523d3cb8ece", null ], [ "mi_register_error", "group__extended.html#gaa1d55e0e894be240827e5d87ec3a1f45", null ], [ "mi_register_output", "group__extended.html#gae5b17ff027cd2150b43a33040250cf3f", null ], diff --git a/docs/index.html b/docs/index.html index ce9c983d..01af9bec 100644 --- a/docs/index.html +++ b/docs/index.html @@ -105,13 +105,14 @@ $(document).ready(function(){initNavTree('index.html','');});

This is the API documentation of the mimalloc allocator (pronounced "me-malloc") – a general purpose allocator with excellent performance characteristics. Initially developed by Daan Leijen for the run-time systems of the Koka and Lean languages.

It is a drop-in replacement for malloc and can be used in other programs without code changes, for example, on Unix you can use it as:

> LD_PRELOAD=/usr/bin/libmimalloc.so myprogram

Notable aspects of the design include:

    -
  • small and consistent: the library is less than 6k LOC using simple and consistent data structures. This makes it very suitable to integrate and adapt in other projects. For runtime systems it provides hooks for a monotonic heartbeat and deferred freeing (for bounded worst-case times with reference counting).
  • -
  • free list sharding: the big idea: instead of one big free list (per size class) we have many smaller lists per memory "page" which both reduces fragmentation and increases locality – things that are allocated close in time get allocated close in memory. (A memory "page" in mimalloc contains blocks of one size class and is usually 64KiB on a 64-bit system).
  • +
  • small and consistent: the library is about 8k LOC using simple and consistent data structures. This makes it very suitable to integrate and adapt in other projects. For runtime systems it provides hooks for a monotonic heartbeat and deferred freeing (for bounded worst-case times with reference counting).
  • +
  • free list sharding: instead of one big free list (per size class) we have many smaller lists per "mimalloc page" which reduces fragmentation and increases locality – things that are allocated close in time get allocated close in memory. (A mimalloc page contains blocks of one size class and is usually 64KiB on a 64-bit system).
  • +
  • free list multi-sharding: the big idea! Not only do we shard the free list per mimalloc page, but for each page we have multiple free lists. In particular, there is one list for thread-local free operations, and another one for concurrent free operations. Free-ing from another thread can now be a single CAS without needing sophisticated coordination between threads. Since there will be thousands of separate free lists, contention is naturally distributed over the heap, and the chance of contending on a single location will be low – this is quite similar to randomized algorithms like skip lists where adding a random oracle removes the need for a more complex algorithm.
  • eager page reset: when a "page" becomes empty (with increased chance due to free list sharding) the memory is marked to the OS as unused ("reset" or "purged") reducing (real) memory pressure and fragmentation, especially in long running programs.
  • secure: mimalloc can be build in secure mode, adding guard pages, randomized allocation, encrypted free lists, etc. to protect against various heap vulnerabilities. The performance penalty is only around 3% on average over our benchmarks.
  • first-class heaps: efficiently create and use multiple heaps to allocate across different regions. A heap can be destroyed at once instead of deallocating each object separately.
  • bounded: it does not suffer from blowup [1], has bounded worst-case allocation times (wcat), bounded space overhead (~0.2% meta-data, with at most 12.5% waste in allocation sizes), and has no internal points of contention using only atomic operations.
  • -
  • fast: In our benchmarks (see below), mimalloc always outperforms all other leading allocators (jemalloc, tcmalloc, Hoard, etc), and usually uses less memory (up to 25% more in the worst case). A nice property is that it does consistently well over a wide range of benchmarks.
  • +
  • fast: In our benchmarks (see below), mimalloc outperforms all other leading allocators (jemalloc, tcmalloc, Hoard, etc), and usually uses less memory (up to 25% more in the worst case). A nice property is that it does consistently well over a wide range of benchmarks.

You can read more on the design of mimalloc in the technical report which also has detailed benchmark results.

Further information:

diff --git a/docs/mimalloc-doc_8h_source.html b/docs/mimalloc-doc_8h_source.html index cbff636b..6d2e86ff 100644 --- a/docs/mimalloc-doc_8h_source.html +++ b/docs/mimalloc-doc_8h_source.html @@ -102,12 +102,11 @@ $(document).ready(function(){initNavTree('mimalloc-doc_8h_source.html','');});
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 
83 
87 
91 void mi_free(void* p);
92 
97 void* mi_malloc(size_t size);
98 
103 void* mi_zalloc(size_t size);
104 
114 void* mi_calloc(size_t count, size_t size);
115 
128 void* mi_realloc(void* p, size_t newsize);
129 
140 void* mi_recalloc(void* p, size_t count, size_t size);
141 
155 void* mi_expand(void* p, size_t newsize);
156 
166 void* mi_mallocn(size_t count, size_t size);
167 
177 void* mi_reallocn(void* p, size_t count, size_t size);
178 
195 void* mi_reallocf(void* p, size_t newsize);
196 
197 
206 char* mi_strdup(const char* s);
207 
217 char* mi_strndup(const char* s, size_t n);
218 
231 char* mi_realpath(const char* fname, char* resolved_name);
232 
234 
235 // ------------------------------------------------------
236 // Extended functionality
237 // ------------------------------------------------------
238 
242 
245 #define MI_SMALL_SIZE_MAX (128*sizeof(void*))
246 
254 void* mi_malloc_small(size_t size);
255 
263 void* mi_zalloc_small(size_t size);
264 
279 size_t mi_usable_size(void* p);
280 
290 size_t mi_good_size(size_t size);
291 
299 void mi_collect(bool force);
300 
305 void mi_stats_print(void* out);
306 
312 void mi_stats_print_out(mi_output_fun* out, void* arg);
313 
315 void mi_stats_reset(void);
316 
318 void mi_stats_merge(void);
319 
323 void mi_thread_init(void);
324 
329 void mi_thread_done(void);
330 
336 void mi_thread_stats_print_out(mi_output_fun* out, void* arg);
337 
344 typedef void (mi_deferred_free_fun)(bool force, unsigned long long heartbeat, void* arg);
345 
361 void mi_register_deferred_free(mi_deferred_free_fun* deferred_free, void* arg);
362 
368 typedef void (mi_output_fun)(const char* msg, void* arg);
369 
376 void mi_register_output(mi_output_fun* out, void* arg);
377 
383 typedef void (mi_error_fun)(int err, void* arg);
384 
400 void mi_register_error(mi_error_fun* errfun, void* arg);
401 
406 bool mi_is_in_heap_region(const void* p);
407 
408 
421 int mi_reserve_huge_os_pages_interleave(size_t pages, size_t numa_nodes, size_t timeout_msecs);
422 
435 int mi_reserve_huge_os_pages_at(size_t pages, int numa_node, size_t timeout_msecs);
436 
437 
442 bool mi_is_redirected();
443 
456 void mi_process_info(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);
457 
459 
460 // ------------------------------------------------------
461 // Aligned allocation
462 // ------------------------------------------------------
463 
469 
482 void* mi_malloc_aligned(size_t size, size_t alignment);
483 void* mi_zalloc_aligned(size_t size, size_t alignment);
484 void* mi_calloc_aligned(size_t count, size_t size, size_t alignment);
485 void* mi_realloc_aligned(void* p, size_t newsize, size_t alignment);
486 
497 void* mi_malloc_aligned_at(size_t size, size_t alignment, size_t offset);
498 void* mi_zalloc_aligned_at(size_t size, size_t alignment, size_t offset);
499 void* mi_calloc_aligned_at(size_t count, size_t size, size_t alignment, size_t offset);
500 void* mi_realloc_aligned_at(void* p, size_t newsize, size_t alignment, size_t offset);
501 
503 
509 
514 struct mi_heap_s;
515 
520 typedef struct mi_heap_s mi_heap_t;
521 
524 
532 void mi_heap_delete(mi_heap_t* heap);
533 
541 void mi_heap_destroy(mi_heap_t* heap);
542 
547 
551 
558 
560 void mi_heap_collect(mi_heap_t* heap, bool force);
561 
564 void* mi_heap_malloc(mi_heap_t* heap, size_t size);
565 
569 void* mi_heap_malloc_small(mi_heap_t* heap, size_t size);
570 
573 void* mi_heap_zalloc(mi_heap_t* heap, size_t size);
574 
577 void* mi_heap_calloc(mi_heap_t* heap, size_t count, size_t size);
578 
581 void* mi_heap_mallocn(mi_heap_t* heap, size_t count, size_t size);
582 
585 char* mi_heap_strdup(mi_heap_t* heap, const char* s);
586 
589 char* mi_heap_strndup(mi_heap_t* heap, const char* s, size_t n);
590 
593 char* mi_heap_realpath(mi_heap_t* heap, const char* fname, char* resolved_name);
594 
595 void* mi_heap_realloc(mi_heap_t* heap, void* p, size_t newsize);
596 void* mi_heap_reallocn(mi_heap_t* heap, void* p, size_t count, size_t size);
597 void* mi_heap_reallocf(mi_heap_t* heap, void* p, size_t newsize);
598 
599 void* mi_heap_malloc_aligned(mi_heap_t* heap, size_t size, size_t alignment);
600 void* mi_heap_malloc_aligned_at(mi_heap_t* heap, size_t size, size_t alignment, size_t offset);
601 void* mi_heap_zalloc_aligned(mi_heap_t* heap, size_t size, size_t alignment);
602 void* mi_heap_zalloc_aligned_at(mi_heap_t* heap, size_t size, size_t alignment, size_t offset);
603 void* mi_heap_calloc_aligned(mi_heap_t* heap, size_t count, size_t size, size_t alignment);
604 void* mi_heap_calloc_aligned_at(mi_heap_t* heap, size_t count, size_t size, size_t alignment, size_t offset);
605 void* mi_heap_realloc_aligned(mi_heap_t* heap, void* p, size_t newsize, size_t alignment);
606 void* mi_heap_realloc_aligned_at(mi_heap_t* heap, void* p, size_t newsize, size_t alignment, size_t offset);
607 
609 
610 
619 
620 void* mi_rezalloc(void* p, size_t newsize);
621 void* mi_recalloc(void* p, size_t newcount, size_t size) ;
622 
623 void* mi_rezalloc_aligned(void* p, size_t newsize, size_t alignment);
624 void* mi_rezalloc_aligned_at(void* p, size_t newsize, size_t alignment, size_t offset);
625 void* mi_recalloc_aligned(void* p, size_t newcount, size_t size, size_t alignment);
626 void* mi_recalloc_aligned_at(void* p, size_t newcount, size_t size, size_t alignment, size_t offset);
627 
628 void* mi_heap_rezalloc(mi_heap_t* heap, void* p, size_t newsize);
629 void* mi_heap_recalloc(mi_heap_t* heap, void* p, size_t newcount, size_t size);
630 
631 void* mi_heap_rezalloc_aligned(mi_heap_t* heap, void* p, size_t newsize, size_t alignment);
632 void* mi_heap_rezalloc_aligned_at(mi_heap_t* heap, void* p, size_t newsize, size_t alignment, size_t offset);
633 void* mi_heap_recalloc_aligned(mi_heap_t* heap, void* p, size_t newcount, size_t size, size_t alignment);
634 void* mi_heap_recalloc_aligned_at(mi_heap_t* heap, void* p, size_t newcount, size_t size, size_t alignment, size_t offset);
635 
637 
646 
658 #define mi_malloc_tp(tp) ((tp*)mi_malloc(sizeof(tp)))
659 
661 #define mi_zalloc_tp(tp) ((tp*)mi_zalloc(sizeof(tp)))
662 
664 #define mi_calloc_tp(tp,count) ((tp*)mi_calloc(count,sizeof(tp)))
665 
667 #define mi_mallocn_tp(tp,count) ((tp*)mi_mallocn(count,sizeof(tp)))
668 
670 #define mi_reallocn_tp(p,tp,count) ((tp*)mi_reallocn(p,count,sizeof(tp)))
671 
673 #define mi_heap_malloc_tp(hp,tp) ((tp*)mi_heap_malloc(hp,sizeof(tp)))
674 
676 #define mi_heap_zalloc_tp(hp,tp) ((tp*)mi_heap_zalloc(hp,sizeof(tp)))
677 
679 #define mi_heap_calloc_tp(hp,tp,count) ((tp*)mi_heap_calloc(hp,count,sizeof(tp)))
680 
682 #define mi_heap_mallocn_tp(hp,tp,count) ((tp*)mi_heap_mallocn(hp,count,sizeof(tp)))
683 
685 #define mi_heap_reallocn_tp(hp,p,tp,count) ((tp*)mi_heap_reallocn(p,count,sizeof(tp)))
686 
688 #define mi_heap_recalloc_tp(hp,p,tp,count) ((tp*)mi_heap_recalloc(p,count,sizeof(tp)))
689 
691 
697 
704 bool mi_heap_contains_block(mi_heap_t* heap, const void* p);
705 
714 bool mi_heap_check_owned(mi_heap_t* heap, const void* p);
715 
723 bool mi_check_owned(const void* p);
724 
727 typedef struct mi_heap_area_s {
728  void* blocks;
729  size_t reserved;
730  size_t committed;
731  size_t used;
732  size_t block_size;
734 
742 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);
743 
755 bool mi_heap_visit_blocks(const mi_heap_t* heap, bool visit_all_blocks, mi_block_visit_fun* visitor, void* arg);
756 
758 
764 
766 typedef enum mi_option_e {
767  // stable options
771  // the following options are experimental
785 } mi_option_t;
786 
787 
788 bool mi_option_is_enabled(mi_option_t option);
789 void mi_option_enable(mi_option_t option);
790 void mi_option_disable(mi_option_t option);
791 void mi_option_set_enabled(mi_option_t option, bool enable);
792 void mi_option_set_enabled_default(mi_option_t option, bool enable);
793 
794 long mi_option_get(mi_option_t option);
795 void mi_option_set(mi_option_t option, long value);
796 void mi_option_set_default(mi_option_t option, long value);
797 
798 
800 
807 
808 void* mi_recalloc(void* p, size_t count, size_t size);
809 size_t mi_malloc_size(const void* p);
810 size_t mi_malloc_usable_size(const void *p);
811 
813 void mi_cfree(void* p);
814 
815 int mi_posix_memalign(void** p, size_t alignment, size_t size);
816 int mi__posix_memalign(void** p, size_t alignment, size_t size);
817 void* mi_memalign(size_t alignment, size_t size);
818 void* mi_valloc(size_t size);
819 
820 void* mi_pvalloc(size_t size);
821 void* mi_aligned_alloc(size_t alignment, size_t size);
822 void* mi_reallocarray(void* p, size_t count, size_t size);
823 
824 void mi_free_size(void* p, size_t size);
825 void mi_free_size_aligned(void* p, size_t size, size_t alignment);
826 void mi_free_aligned(void* p, size_t alignment);
827 
829 
842 
844 void* mi_new(std::size_t n) noexcept(false);
845 
847 void* mi_new_n(size_t count, size_t size) noexcept(false);
848 
850 void* mi_new_aligned(std::size_t n, std::align_val_t alignment) noexcept(false);
851 
853 void* mi_new_nothrow(size_t n);
854 
856 void* mi_new_aligned_nothrow(size_t n, size_t alignment);
857 
859 void* mi_new_realloc(void* p, size_t newsize);
860 
862 void* mi_new_reallocn(void* p, size_t newcount, size_t size);
863 
871 template<class T> struct mi_stl_allocator { }
872 
874 
size_t mi_usable_size(void *p)
Return the available bytes in a memory block.
+
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 
533 
541 void mi_heap_delete(mi_heap_t* heap);
542 
550 void mi_heap_destroy(mi_heap_t* heap);
551 
556 
560 
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;
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
780  // the following options are experimental
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 
size_t mi_usable_size(void *p)
Return the available bytes in a memory block.
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_reallocn(void *p, size_t count, size_t size)
Re-allocate memory to count elements of size bytes.
void * mi_malloc_aligned(size_t size, size_t alignment)
Allocate size bytes aligned by alignment.
void * mi_recalloc_aligned_at(void *p, size_t newcount, size_t size, size_t alignment, size_t offset)
-
void mi_process_info(size_t *user_msecs, size_t *system_msecs, size_t *current_rss, size_t *peak_rss, size_t *current_commit, size_t *peak_commit, size_t *page_faults)
Return process information (time and memory usage).
void mi_stats_reset(void)
Reset statistics.
void * mi_heap_realloc_aligned(mi_heap_t *heap, void *p, size_t newsize, size_t alignment)
bool mi_option_is_enabled(mi_option_t option)
@@ -121,17 +120,17 @@ $(document).ready(function(){initNavTree('mimalloc-doc_8h_source.html','');});
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...
void mi_option_set_default(mi_option_t option, long value)
void mi_stats_print_out(mi_output_fun *out, void *arg)
Print the main statistics.
-
void() mi_error_fun(int err, void *arg)
Type of error callback functions.
Definition: mimalloc-doc.h:383
+
void() mi_error_fun(int err, void *arg)
Type of error callback functions.
Definition: mimalloc-doc.h:391
void * mi_rezalloc(void *p, size_t newsize)
-
Eagerly commit segments (4MiB) (enabled by default).
Definition: mimalloc-doc.h:772
+
Eagerly commit segments (4MiB) (enabled by default).
Definition: mimalloc-doc.h:781
void * mi_heap_zalloc(mi_heap_t *heap, size_t size)
Allocate zero-initialized in a specific heap.
void mi_option_set(mi_option_t option, long value)
-
Eagerly commit large (256MiB) memory regions (enabled by default, except on Windows)
Definition: mimalloc-doc.h:773
+
Eagerly commit large (256MiB) memory regions (enabled by default, except on Windows)
Definition: mimalloc-doc.h:782
void mi_cfree(void *p)
Just as free but also checks if the pointer p belongs to our heap.
void * mi_recalloc_aligned(void *p, size_t newcount, size_t size, size_t alignment)
-
Definition: mimalloc-doc.h:784
+
Definition: mimalloc-doc.h:793
void * mi_realloc_aligned_at(void *p, size_t newsize, size_t alignment, size_t offset)
-
void * blocks
start of the area containing heap blocks
Definition: mimalloc-doc.h:728
+
void * blocks
start of the area containing heap blocks
Definition: mimalloc-doc.h:737
void * mi_realloc_aligned(void *p, size_t newsize, size_t alignment)
void mi_option_enable(mi_option_t option)
int mi__posix_memalign(void **p, size_t alignment, size_t size)
@@ -139,6 +138,7 @@ $(document).ready(function(){initNavTree('mimalloc-doc_8h_source.html','');});
char * mi_heap_strdup(mi_heap_t *heap, const char *s)
Duplicate a string in a specific heap.
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.
void * mi_heap_calloc_aligned_at(mi_heap_t *heap, size_t count, size_t size, size_t alignment, size_t offset)
+
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_calloc_aligned(size_t count, size_t size, size_t alignment)
void * mi_heap_zalloc_aligned(mi_heap_t *heap, size_t size, size_t alignment)
void * mi_zalloc_small(size_t size)
Allocate a zero initialized small object.
@@ -149,35 +149,35 @@ $(document).ready(function(){initNavTree('mimalloc-doc_8h_source.html','');});
void * mi_heap_rezalloc_aligned_at(mi_heap_t *heap, void *p, size_t newsize, size_t alignment, size_t offset)
void * mi_zalloc(size_t size)
Allocate zero-initialized size bytes.
void * mi_heap_rezalloc(mi_heap_t *heap, void *p, size_t newsize)
-
The number of segments per thread to keep cached.
Definition: mimalloc-doc.h:776
+
The number of segments per thread to keep cached.
Definition: mimalloc-doc.h:785
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_calloc_aligned(mi_heap_t *heap, size_t count, size_t size, size_t alignment)
bool mi_is_redirected()
Is the C runtime malloc API redirected?
-
size_t block_size
size in bytes of one block
Definition: mimalloc-doc.h:732
+
size_t block_size
size in bytes of one block
Definition: mimalloc-doc.h:741
void * mi_reallocarray(void *p, size_t count, size_t size)
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...
-
void() mi_deferred_free_fun(bool force, unsigned long long heartbeat, void *arg)
Type of deferred free functions.
Definition: mimalloc-doc.h:344
+
void() mi_deferred_free_fun(bool force, unsigned long long heartbeat, void *arg)
Type of deferred free functions.
Definition: mimalloc-doc.h:352
bool mi_is_in_heap_region(const void *p)
Is a pointer part of our heap?
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_realloc(void *p, size_t newsize)
Re-allocate memory to newsize bytes.
-
The number of huge OS pages (1GiB in size) to reserve at the start of the program.
Definition: mimalloc-doc.h:775
+
The number of huge OS pages (1GiB in size) to reserve at the start of the program.
Definition: mimalloc-doc.h:784
void * mi_heap_reallocf(mi_heap_t *heap, void *p, size_t newsize)
void mi_free_size_aligned(void *p, size_t size, size_t alignment)
void * mi_rezalloc_aligned_at(void *p, size_t newsize, size_t alignment, size_t offset)
-
Reset page memory after mi_option_reset_delay milliseconds when it becomes free.
Definition: mimalloc-doc.h:777
+
Reset page memory after mi_option_reset_delay milliseconds when it becomes free.
Definition: mimalloc-doc.h:786
void mi_thread_done(void)
Uninitialize mimalloc on a thread.
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.
-
Pretend there are at most N NUMA nodes.
Definition: mimalloc-doc.h:780
+
Pretend there are at most N NUMA nodes.
Definition: mimalloc-doc.h:789
void * mi_malloc(size_t size)
Allocate size bytes.
void mi_register_error(mi_error_fun *errfun, void *arg)
Register an error callback function.
-
Experimental.
Definition: mimalloc-doc.h:781
+
Experimental.
Definition: mimalloc-doc.h:790
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.
-
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:742
+
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
void * mi_heap_recalloc(mi_heap_t *heap, void *p, size_t newcount, size_t size)
void * mi_heap_malloc_aligned_at(mi_heap_t *heap, size_t size, size_t alignment, size_t offset)
char * mi_realpath(const char *fname, char *resolved_name)
Resolve a file path name.
-
Print error messages to stderr.
Definition: mimalloc-doc.h:768
-
Experimental.
Definition: mimalloc-doc.h:778
+
Print error messages to stderr.
Definition: mimalloc-doc.h:777
+
Experimental.
Definition: mimalloc-doc.h:787
void * mi_heap_rezalloc_aligned(mi_heap_t *heap, void *p, size_t newsize, size_t alignment)
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_memalign(size_t alignment, size_t size)
@@ -185,11 +185,11 @@ $(document).ready(function(){initNavTree('mimalloc-doc_8h_source.html','');});
bool mi_heap_contains_block(mi_heap_t *heap, const void *p)
Does a heap contain a pointer to a previously allocated block?
void mi_heap_collect(mi_heap_t *heap, bool force)
Release outstanding resources in a specific heap.
void * mi_heap_recalloc_aligned_at(mi_heap_t *heap, void *p, size_t newcount, size_t size, size_t alignment, size_t offset)
-
Print verbose messages to stderr.
Definition: mimalloc-doc.h:770
+
Print verbose messages to stderr.
Definition: mimalloc-doc.h:779
void * mi_zalloc_aligned_at(size_t size, size_t alignment, size_t offset)
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_heap_delete(mi_heap_t *heap)
Delete a previously allocated heap.
-
OS tag to assign to mimalloc'd memory.
Definition: mimalloc-doc.h:783
+
OS tag to assign to mimalloc'd memory.
Definition: mimalloc-doc.h:792
mi_heap_t * mi_heap_get_default()
Get the default heap that is used for mi_malloc() et al.
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_option_disable(mi_option_t option)
@@ -198,30 +198,30 @@ $(document).ready(function(){initNavTree('mimalloc-doc_8h_source.html','');});
void mi_thread_init(void)
Initialize mimalloc on a thread.
size_t mi_good_size(size_t size)
Return the used allocation size.
void mi_stats_print(void *out)
Deprecated.
-
Experimental.
Definition: mimalloc-doc.h:782
+
Experimental.
Definition: mimalloc-doc.h:791
void * mi_heap_recalloc_aligned(mi_heap_t *heap, void *p, size_t newcount, size_t size, size_t alignment)
void * mi_heap_mallocn(mi_heap_t *heap, size_t count, size_t size)
Allocate count elements in a specific heap.
-
An area of heap space contains blocks of a single size.
Definition: mimalloc-doc.h:727
+
An area of heap space contains blocks of a single size.
Definition: mimalloc-doc.h:736
void mi_thread_stats_print_out(mi_output_fun *out, void *arg)
Print out heap statistics for this thread.
-
Print statistics to stderr when the program is done.
Definition: mimalloc-doc.h:769
+
Print statistics to stderr when the program is done.
Definition: mimalloc-doc.h:778
void * mi_zalloc_aligned(size_t size, size_t alignment)
-
size_t reserved
bytes reserved for this area
Definition: mimalloc-doc.h:729
-
struct mi_heap_s mi_heap_t
Type of first-class heaps.
Definition: mimalloc-doc.h:520
-
size_t used
bytes in use by allocated blocks
Definition: mimalloc-doc.h:731
+
size_t reserved
bytes reserved for this area
Definition: mimalloc-doc.h:738
+
struct mi_heap_s mi_heap_t
Type of first-class heaps.
Definition: mimalloc-doc.h:529
+
size_t used
bytes in use by allocated blocks
Definition: mimalloc-doc.h:740
void mi_register_deferred_free(mi_deferred_free_fun *deferred_free, void *arg)
Register a deferred free function.
void mi_free_size(void *p, size_t size)
void mi_collect(bool force)
Eagerly free memory.
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_heap_destroy(mi_heap_t *heap)
Destroy a heap, freeing all its still allocated blocks.
void * mi_calloc_aligned_at(size_t count, size_t size, size_t alignment, size_t offset)
-
Use large OS pages (2MiB in size) if possible.
Definition: mimalloc-doc.h:774
+
Use large OS pages (2MiB in size) if possible.
Definition: mimalloc-doc.h:783
void * mi_heap_reallocn(mi_heap_t *heap, void *p, size_t count, size_t size)
void mi_register_output(mi_output_fun *out, void *arg)
Register an output function.
-
std::allocator implementation for mimalloc for use in STL containers.
Definition: mimalloc-doc.h:871
+
std::allocator implementation for mimalloc for use in STL containers.
Definition: mimalloc-doc.h:880
void * mi_heap_malloc_small(mi_heap_t *heap, size_t size)
Allocate a small object in a specific heap.
void * mi_heap_realloc(mi_heap_t *heap, void *p, size_t newsize)
size_t mi_malloc_usable_size(const void *p)
-
void() mi_output_fun(const char *msg, void *arg)
Type of output functions.
Definition: mimalloc-doc.h:368
+
void() mi_output_fun(const char *msg, void *arg)
Type of output functions.
Definition: mimalloc-doc.h:376
char * mi_strdup(const char *s)
Allocate and duplicate a string.
void * mi_heap_realloc_aligned_at(mi_heap_t *heap, void *p, size_t newsize, size_t alignment, size_t offset)
void * mi_reallocf(void *p, size_t newsize)
Re-allocate memory to newsize bytes,.
@@ -234,11 +234,11 @@ $(document).ready(function(){initNavTree('mimalloc-doc_8h_source.html','');});
mi_heap_t * mi_heap_get_backing()
Get the backing heap.
void mi_free_aligned(void *p, size_t alignment)
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...
-
Delay in milli-seconds before resetting a page (100ms by default)
Definition: mimalloc-doc.h:779
+
Delay in milli-seconds before resetting a page (100ms by default)
Definition: mimalloc-doc.h:788
mi_heap_t * mi_heap_new()
Create a new heap that can be used for allocation.
void * mi_heap_malloc(mi_heap_t *heap, size_t size)
Allocate in a specific heap.
-
size_t committed
current committed bytes of this area
Definition: mimalloc-doc.h:730
-
mi_option_t
Runtime options.
Definition: mimalloc-doc.h:766
+
size_t committed
current committed bytes of this area
Definition: mimalloc-doc.h:739
+
mi_option_t
Runtime options.
Definition: mimalloc-doc.h:775
bool mi_heap_check_owned(mi_heap_t *heap, const void *p)
Check safely if any pointer is part of a heap.
mi_heap_t * mi_heap_set_default(mi_heap_t *heap)
Set the default heap to use for mi_malloc() et al.
diff --git a/docs/navtreeindex0.js b/docs/navtreeindex0.js index 92f8d8c9..4a1e93fa 100644 --- a/docs/navtreeindex0.js +++ b/docs/navtreeindex0.js @@ -53,8 +53,8 @@ var NAVTREEINDEX0 = "group__extended.html#ga5f071b10d4df1c3658e04e7fd67a94e6":[5,1,6], "group__extended.html#ga7136c2e55cb22c98ecf95d08d6debb99":[5,1,8], "group__extended.html#ga7795a13d20087447281858d2c771cca1":[5,1,13], +"group__extended.html#ga7d862c2affd5790381da14eb102a364d":[5,1,9], "group__extended.html#ga854b1de8cb067c7316286c28b2fcd3d1":[5,1,15], -"group__extended.html#ga9144506d5ffa8cc03547867bd15e1032":[5,1,9], "group__extended.html#gaa1d55e0e894be240827e5d87ec3a1f45":[5,1,11], "group__extended.html#gaad25050b19f30cd79397b227e0157a3f":[5,1,7], "group__extended.html#gab1dac8476c46cb9eecab767eb40c1525":[5,1,21], diff --git a/docs/search/all_6.js b/docs/search/all_6.js index 4e4c8a3f..491883f4 100644 --- a/docs/search/all_6.js +++ b/docs/search/all_6.js @@ -106,7 +106,7 @@ var searchData= ['mi_5foption_5fverbose',['mi_option_verbose',['../group__options.html#ggafebf7ed116adb38ae5218bc3ce06884ca7c8b7bf5281c581bad64f5daa6442777',1,'mimalloc-doc.h']]], ['mi_5foutput_5ffun',['mi_output_fun',['../group__extended.html#gad823d23444a4b77a40f66bf075a98a0c',1,'mimalloc-doc.h']]], ['mi_5fposix_5fmemalign',['mi_posix_memalign',['../group__posix.html#gacff84f226ba9feb2031b8992e5579447',1,'mimalloc-doc.h']]], - ['mi_5fprocess_5finfo',['mi_process_info',['../group__extended.html#ga9144506d5ffa8cc03547867bd15e1032',1,'mimalloc-doc.h']]], + ['mi_5fprocess_5finfo',['mi_process_info',['../group__extended.html#ga7d862c2affd5790381da14eb102a364d',1,'mimalloc-doc.h']]], ['mi_5fpvalloc',['mi_pvalloc',['../group__posix.html#gaeb325c39b887d3b90d85d1eb1712fb1e',1,'mimalloc-doc.h']]], ['mi_5frealloc',['mi_realloc',['../group__malloc.html#gaf11eb497da57bdfb2de65eb191c69db6',1,'mimalloc-doc.h']]], ['mi_5frealloc_5faligned',['mi_realloc_aligned',['../group__aligned.html#ga4028d1cf4aa4c87c880747044a8322ae',1,'mimalloc-doc.h']]], diff --git a/docs/search/functions_0.js b/docs/search/functions_0.js index fc333d5f..b188b270 100644 --- a/docs/search/functions_0.js +++ b/docs/search/functions_0.js @@ -75,7 +75,7 @@ var searchData= ['mi_5foption_5fset_5fenabled',['mi_option_set_enabled',['../group__options.html#ga9a13d05fcb77489cb06d4d017ebd8bed',1,'mimalloc-doc.h']]], ['mi_5foption_5fset_5fenabled_5fdefault',['mi_option_set_enabled_default',['../group__options.html#ga65518b69ec5d32336b50e07f74b3f629',1,'mimalloc-doc.h']]], ['mi_5fposix_5fmemalign',['mi_posix_memalign',['../group__posix.html#gacff84f226ba9feb2031b8992e5579447',1,'mimalloc-doc.h']]], - ['mi_5fprocess_5finfo',['mi_process_info',['../group__extended.html#ga9144506d5ffa8cc03547867bd15e1032',1,'mimalloc-doc.h']]], + ['mi_5fprocess_5finfo',['mi_process_info',['../group__extended.html#ga7d862c2affd5790381da14eb102a364d',1,'mimalloc-doc.h']]], ['mi_5fpvalloc',['mi_pvalloc',['../group__posix.html#gaeb325c39b887d3b90d85d1eb1712fb1e',1,'mimalloc-doc.h']]], ['mi_5frealloc',['mi_realloc',['../group__malloc.html#gaf11eb497da57bdfb2de65eb191c69db6',1,'mimalloc-doc.h']]], ['mi_5frealloc_5faligned',['mi_realloc_aligned',['../group__aligned.html#ga4028d1cf4aa4c87c880747044a8322ae',1,'mimalloc-doc.h']]], diff --git a/readme.md b/readme.md index accd09cb..9419a658 100644 --- a/readme.md +++ b/readme.md @@ -11,7 +11,7 @@ mimalloc (pronounced "me-malloc") is a general purpose allocator with excellent [performance](#performance) characteristics. Initially developed by Daan Leijen for the run-time systems of the [Koka](https://github.com/koka-lang/koka) and [Lean](https://github.com/leanprover/lean) languages. -Latest release:`v1.6.5` (2020-09-24). +Latest release:`v1.6.7` (2020-09-24). It is a drop-in replacement for `malloc` and can be used in other programs without code changes, for example, on dynamically linked ELF-based systems (Linux, BSD, etc.) you can use it as: @@ -73,8 +73,8 @@ Enjoy! ### Releases -* 2020-09-24, `v1.6.6`: stable release 1.6: using standard C atomics, passing tsan testing, improved - handling of failing to commit on Windows, add `mi_process_info` api call. +* 2020-09-24, `v1.6.7`: stable release 1.6: using standard C atomics, passing tsan testing, improved + handling of failing to commit on Windows, add [`mi_process_info`](https://github.com/microsoft/mimalloc/blob/master/include/mimalloc.h#L156) api call. * 2020-08-06, `v1.6.4`: stable release 1.6: improved error recovery in low-memory situations, support for IllumOS and Haiku, NUMA support for Vista/XP, improved NUMA detection for AMD Ryzen, ubsan support. * 2020-05-05, `v1.6.3`: stable release 1.6: improved behavior in out-of-memory situations, improved malloc zones on macOS, diff --git a/src/alloc.c b/src/alloc.c index 590952d4..b2e0531d 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -448,8 +448,7 @@ void mi_free(void* p) mi_attr_noexcept #endif mi_block_set_next(page, block, page->local_free); page->local_free = block; - page->used--; - if (mi_unlikely(mi_page_all_free(page))) { + if (mi_unlikely(--page->used == 0)) { // using this expression generates better code than: page->used--; if (mi_page_all_free(page)) _mi_page_retire(page); } } diff --git a/src/region.c b/src/region.c index 8afa80a2..663859c8 100644 --- a/src/region.c +++ b/src/region.c @@ -243,7 +243,7 @@ static bool mi_region_is_suitable(const mem_region_t* region, int numa_node, boo static bool mi_region_try_claim(int numa_node, size_t blocks, bool allow_large, mem_region_t** region, mi_bitmap_index_t* bit_idx, mi_os_tld_t* tld) { // try all regions for a free slot - const size_t count = mi_atomic_load_acquire(®ions_count); + const size_t count = mi_atomic_load_relaxed(®ions_count); // monotonic, so ok to be relaxed size_t idx = tld->region_idx; // Or start at 0 to reuse low addresses? Starting at 0 seems to increase latency though for (size_t visited = 0; visited < count; visited++, idx++) { if (idx >= count) idx = 0; // wrap around
user_msecsOptional. User time in milli-seconds.
elapsed_msecsOptional. Elapsed wall-clock time of the process in milli-seconds.
user_msecsOptional. User time in milli-seconds (as the sum over all threads).
system_msecsOptional. System time in milli-seconds.
current_rssOptional. Current working set size (touched pages).
peak_rssOptional. Peak working set size (touched pages).