diff --git a/include/mimalloc.h b/include/mimalloc.h index 2bcbf10e..ea79a522 100644 --- a/include/mimalloc.h +++ b/include/mimalloc.h @@ -311,6 +311,7 @@ typedef enum mi_option_e { mi_option_eager_commit_delay, mi_option_reset_delay, mi_option_use_numa_nodes, + mi_option_limit_os_alloc, mi_option_os_tag, mi_option_max_errors, _mi_option_last diff --git a/src/arena.c b/src/arena.c index 91cac309..a6ea4125 100644 --- a/src/arena.c +++ b/src/arena.c @@ -197,6 +197,7 @@ void* _mi_arena_alloc_aligned(size_t size, size_t alignment, bool* commit, bool* } // finally, fall back to the OS + if (mi_option_is_enabled(mi_option_limit_os_alloc)) return NULL; *is_zero = true; *memid = MI_MEMID_OS; void* p = _mi_os_alloc_aligned(size, alignment, *commit, large, tld->stats); @@ -326,7 +327,7 @@ int mi_reserve_os_memory(size_t size, bool commit, bool allow_large) mi_attr_noe _mi_verbose_message("failed to reserve %zu k memory\n", _mi_divide_up(size,1024)); return ENOMEM; } - _mi_verbose_message("reserved %zu kb memory\n", _mi_divide_up(size,1024)); + _mi_verbose_message("reserved %zu kb memory%s\n", _mi_divide_up(size,1024), large ? " (in large os pages)" : ""); return 0; } diff --git a/src/options.c b/src/options.c index 9da3a9bd..7e565ea4 100644 --- a/src/options.c +++ b/src/options.c @@ -86,6 +86,7 @@ static mi_option_desc_t options[_mi_option_last] = #endif { 100, UNINIT, MI_OPTION(reset_delay) }, // reset delay in milli-seconds { 0, UNINIT, MI_OPTION(use_numa_nodes) }, // 0 = use available numa nodes, otherwise use at most N nodes. + { 0, UNINIT, MI_OPTION(limit_os_alloc) }, // 1 = do not use OS memory for allocation (but only reserved arenas) { 100, UNINIT, MI_OPTION(os_tag) }, // only apple specific for now but might serve more or less related purpose { 16, UNINIT, MI_OPTION(max_errors) } // maximum errors that are output }; diff --git a/test/test-stress.c b/test/test-stress.c index 68faef90..d969284e 100644 --- a/test/test-stress.c +++ b/test/test-stress.c @@ -235,7 +235,7 @@ int main(int argc, char** argv) { if (n > 0) ITER = n; } printf("Using %d threads with a %d%% load-per-thread and %d iterations\n", THREADS, SCALE, ITER); - //mi_reserve_os_memory(512*1024*1024ULL, true, true); + //mi_reserve_os_memory(1024*1024*1024ULL, false, true); //int res = mi_reserve_huge_os_pages(4,1); //printf("(reserve huge: %i\n)", res);