mirror of
https://github.com/microsoft/mimalloc.git
synced 2024-12-27 13:33:18 +08:00
Add MI_SKIP_COLLECT_ON_EXIT flag
This commit is contained in:
parent
076f815cec
commit
d2e727f0e8
@ -23,6 +23,7 @@ option(MI_DEBUG_TSAN "Build with thread sanitizer (needs clang)" OFF)
|
|||||||
option(MI_DEBUG_UBSAN "Build with undefined-behavior sanitizer (needs clang++)" OFF)
|
option(MI_DEBUG_UBSAN "Build with undefined-behavior sanitizer (needs clang++)" OFF)
|
||||||
option(MI_CHECK_FULL "Use full internal invariant checking in DEBUG mode (deprecated, use MI_DEBUG_FULL instead)" OFF)
|
option(MI_CHECK_FULL "Use full internal invariant checking in DEBUG mode (deprecated, use MI_DEBUG_FULL instead)" OFF)
|
||||||
option(MI_INSTALL_TOPLEVEL "Install directly into $CMAKE_INSTALL_PREFIX instead of PREFIX/lib/mimalloc-version" OFF)
|
option(MI_INSTALL_TOPLEVEL "Install directly into $CMAKE_INSTALL_PREFIX instead of PREFIX/lib/mimalloc-version" OFF)
|
||||||
|
option(MI_SKIP_COLLECT_ON_EXIT, "Skip collecting memory on exit" OFF)
|
||||||
|
|
||||||
include("cmake/mimalloc-config-version.cmake")
|
include("cmake/mimalloc-config-version.cmake")
|
||||||
|
|
||||||
@ -102,6 +103,10 @@ if(MI_CHECK_FULL)
|
|||||||
set(MI_DEBUG_FULL "ON")
|
set(MI_DEBUG_FULL "ON")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (MI_SKIP_COLLECT_ON_EXIT)
|
||||||
|
list(APPEND mi_defines MI_SKIP_COLLECT_ON_EXIT=1)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(MI_DEBUG_FULL)
|
if(MI_DEBUG_FULL)
|
||||||
message(STATUS "Set debug level to full internal invariant checking (MI_DEBUG_FULL=ON)")
|
message(STATUS "Set debug level to full internal invariant checking (MI_DEBUG_FULL=ON)")
|
||||||
list(APPEND mi_defines MI_DEBUG=3) # full invariant checking
|
list(APPEND mi_defines MI_DEBUG=3) # full invariant checking
|
||||||
|
12
src/init.c
12
src/init.c
@ -516,11 +516,13 @@ static void mi_process_done(void) {
|
|||||||
FlsFree(mi_fls_key); // call thread-done on all threads to prevent dangling callback pointer if statically linked with a DLL; Issue #208
|
FlsFree(mi_fls_key); // call thread-done on all threads to prevent dangling callback pointer if statically linked with a DLL; Issue #208
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (MI_DEBUG != 0) || !defined(MI_SHARED_LIB)
|
#ifndef MI_SKIP_COLLECT_ON_EXIT
|
||||||
// free all memory if possible on process exit. This is not needed for a stand-alone process
|
#if (MI_DEBUG != 0) || !defined(MI_SHARED_LIB)
|
||||||
// but should be done if mimalloc is statically linked into another shared library which
|
// free all memory if possible on process exit. This is not needed for a stand-alone process
|
||||||
// is repeatedly loaded/unloaded, see issue #281.
|
// but should be done if mimalloc is statically linked into another shared library which
|
||||||
mi_collect(true /* force */ );
|
// is repeatedly loaded/unloaded, see issue #281.
|
||||||
|
mi_collect(true /* force */ );
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (mi_option_is_enabled(mi_option_show_stats) || mi_option_is_enabled(mi_option_verbose)) {
|
if (mi_option_is_enabled(mi_option_show_stats) || mi_option_is_enabled(mi_option_verbose)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user