mirror of
https://github.com/microsoft/mimalloc.git
synced 2024-12-27 13:33:18 +08:00
merge from dev-reset
This commit is contained in:
commit
a836d233ff
@ -318,12 +318,12 @@ mi_decl_export int mi_reserve_huge_os_pages(size_t pages, double max_secs, size
|
|||||||
|
|
||||||
typedef enum mi_option_e {
|
typedef enum mi_option_e {
|
||||||
// stable options
|
// stable options
|
||||||
mi_option_show_errors,
|
mi_option_show_errors, // print error messages
|
||||||
mi_option_show_stats,
|
mi_option_show_stats, // print statistics on termination
|
||||||
mi_option_verbose,
|
mi_option_verbose, // print verbose messages
|
||||||
// some of the following options are experimental
|
// the following options are experimental (see src/options.h)
|
||||||
// (deprecated options are kept for binary backward compatibility with v1.x versions)
|
// (deprecated options are kept for binary backward compatibility with v1.x versions)
|
||||||
mi_option_eager_commit,
|
mi_option_segment_eager_commit,
|
||||||
mi_option_arena_eager_commit,
|
mi_option_arena_eager_commit,
|
||||||
mi_option_purge_decommits,
|
mi_option_purge_decommits,
|
||||||
mi_option_large_os_pages, // use large (2MiB) OS pages, implies eager commit
|
mi_option_large_os_pages, // use large (2MiB) OS pages, implies eager commit
|
||||||
@ -342,13 +342,18 @@ typedef enum mi_option_e {
|
|||||||
mi_option_max_errors,
|
mi_option_max_errors,
|
||||||
mi_option_max_warnings,
|
mi_option_max_warnings,
|
||||||
mi_option_max_segment_reclaim,
|
mi_option_max_segment_reclaim,
|
||||||
mi_option_allow_purge,
|
|
||||||
mi_option_deprecated_segment_decommit_delay,
|
mi_option_deprecated_segment_decommit_delay,
|
||||||
mi_option_purge_extend_delay,
|
mi_option_purge_extend_delay,
|
||||||
mi_option_destroy_on_exit,
|
mi_option_destroy_on_exit,
|
||||||
mi_option_arena_reserve,
|
mi_option_arena_reserve,
|
||||||
mi_option_arena_purge_delay,
|
mi_option_arena_purge_delay,
|
||||||
_mi_option_last
|
mi_option_allow_purge,
|
||||||
|
_mi_option_last,
|
||||||
|
// legacy options
|
||||||
|
mi_option_eager_commit = mi_option_segment_eager_commit,
|
||||||
|
mi_option_eager_region_commit = mi_option_arena_eager_commit,
|
||||||
|
mi_option_reset_decommits = mi_option_purge_decommits,
|
||||||
|
mi_option_reset_delay = mi_option_purge_delay
|
||||||
} mi_option_t;
|
} mi_option_t;
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,6 +99,7 @@ bool _mi_os_commit(void* p, size_t size, bool* is_zero, mi_stats_t* stats)
|
|||||||
bool _mi_os_decommit(void* addr, size_t size, mi_stats_t* stats);
|
bool _mi_os_decommit(void* addr, size_t size, mi_stats_t* stats);
|
||||||
bool _mi_os_protect(void* addr, size_t size);
|
bool _mi_os_protect(void* addr, size_t size);
|
||||||
bool _mi_os_unprotect(void* addr, size_t size);
|
bool _mi_os_unprotect(void* addr, size_t size);
|
||||||
|
bool _mi_os_purge(void* p, size_t size, mi_stats_t* stats);
|
||||||
|
|
||||||
void* _mi_os_alloc_aligned(size_t size, size_t alignment, bool commit, bool* large, mi_stats_t* stats);
|
void* _mi_os_alloc_aligned(size_t size, size_t alignment, bool commit, bool* large, mi_stats_t* stats);
|
||||||
void* _mi_os_alloc_aligned_offset(size_t size, size_t alignment, size_t align_offset, bool commit, bool* large, mi_stats_t* tld_stats);
|
void* _mi_os_alloc_aligned_offset(size_t size, size_t alignment, size_t align_offset, bool commit, bool* large, mi_stats_t* tld_stats);
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------------
|
||||||
Copyright (c) 2019-2022, Microsoft Research, Daan Leijen
|
Copyright (c) 2019-2022, Microsoft Research, Daan Leijen
|
||||||
This is free software; you can redistribute it and/or modify it under the
|
This is free software; you can redistribute it and/or modify it under the
|
||||||
@ -190,7 +192,7 @@ static mi_decl_noinline void* mi_arena_alloc_from(mi_arena_t* arena, size_t aren
|
|||||||
*commit = _mi_bitmap_is_claimed_across(arena->blocks_committed, arena->field_count, needed_bcount, bitmap_index);
|
*commit = _mi_bitmap_is_claimed_across(arena->blocks_committed, arena->field_count, needed_bcount, bitmap_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
// mi_track_mem_undefined(p,needed_bcount*MI_ARENA_BLOCK_SIZE);
|
mi_track_mem_undefined(p,needed_bcount*MI_ARENA_BLOCK_SIZE); // todo: should not be needed?
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -752,3 +754,4 @@ int mi_reserve_huge_os_pages(size_t pages, double max_secs, size_t* pages_reserv
|
|||||||
if (err==0 && pages_reserved!=NULL) *pages_reserved = pages;
|
if (err==0 && pages_reserved!=NULL) *pages_reserved = pages;
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,6 @@ static mi_option_desc_t options[_mi_option_last] =
|
|||||||
{ 16, UNINIT, MI_OPTION(max_errors) }, // maximum errors that are output
|
{ 16, UNINIT, MI_OPTION(max_errors) }, // maximum errors that are output
|
||||||
{ 16, UNINIT, MI_OPTION(max_warnings) }, // maximum warnings that are output
|
{ 16, UNINIT, MI_OPTION(max_warnings) }, // maximum warnings that are output
|
||||||
{ 8, UNINIT, MI_OPTION(max_segment_reclaim)},// max. number of segment reclaims from the abandoned segments per try.
|
{ 8, UNINIT, MI_OPTION(max_segment_reclaim)},// max. number of segment reclaims from the abandoned segments per try.
|
||||||
{ 1, UNINIT, MI_OPTION_LEGACY(allow_purge, allow_decommit) }, // decommit slices when no longer used (after decommit_delay milli-seconds)
|
|
||||||
{ 100, UNINIT, MI_OPTION(deprecated_segment_decommit_delay) }, // decommit delay in milli-seconds for freed segments
|
{ 100, UNINIT, MI_OPTION(deprecated_segment_decommit_delay) }, // decommit delay in milli-seconds for freed segments
|
||||||
{ 1, UNINIT, MI_OPTION_LEGACY(purge_extend_delay, decommit_extend_delay) },
|
{ 1, UNINIT, MI_OPTION_LEGACY(purge_extend_delay, decommit_extend_delay) },
|
||||||
{ 0, UNINIT, MI_OPTION(destroy_on_exit)}, // release all OS memory on process exit; careful with dangling pointer or after-exit frees!
|
{ 0, UNINIT, MI_OPTION(destroy_on_exit)}, // release all OS memory on process exit; careful with dangling pointer or after-exit frees!
|
||||||
@ -91,7 +90,8 @@ static mi_option_desc_t options[_mi_option_last] =
|
|||||||
#else
|
#else
|
||||||
{ 128L*1024L, UNINIT, MI_OPTION(arena_reserve) },
|
{ 128L*1024L, UNINIT, MI_OPTION(arena_reserve) },
|
||||||
#endif
|
#endif
|
||||||
{ 100, UNINIT, MI_OPTION(arena_purge_delay) } // reset/decommit delay in milli-seconds for arena allocation
|
{ 100, UNINIT, MI_OPTION(arena_purge_delay) }, // reset/decommit delay in milli-seconds for arena allocation
|
||||||
|
{ 1, UNINIT, MI_OPTION(allow_purge) } // allow decommit/reset to free (physical) memory back to the OS
|
||||||
};
|
};
|
||||||
|
|
||||||
static void mi_option_init(mi_option_desc_t* desc);
|
static void mi_option_init(mi_option_desc_t* desc);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user