File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ option(MI_DEBUG_TSAN "Build with thread sanitizer (needs clang)" OFF)
2323option (MI_DEBUG_UBSAN "Build with undefined-behavior sanitizer (needs clang++)" OFF )
2424option (MI_CHECK_FULL "Use full internal invariant checking in DEBUG mode (deprecated, use MI_DEBUG_FULL instead)" OFF )
2525option (MI_INSTALL_TOPLEVEL "Install directly into $CMAKE_INSTALL_PREFIX instead of PREFIX/lib/mimalloc-version" OFF )
26+ option (MI_SKIP_COLLECT_ON_EXIT, "Skip collecting memory on exit" OFF )
2627
2728include ("cmake/mimalloc-config-version.cmake" )
2829
@@ -102,6 +103,10 @@ if(MI_CHECK_FULL)
102103 set (MI_DEBUG_FULL "ON" )
103104endif ()
104105
106+ if (MI_SKIP_COLLECT_ON_EXIT)
107+ list (APPEND mi_defines MI_SKIP_COLLECT_ON_EXIT=1)
108+ endif ()
109+
105110if (MI_DEBUG_FULL)
106111 message (STATUS "Set debug level to full internal invariant checking (MI_DEBUG_FULL=ON)" )
107112 list (APPEND mi_defines MI_DEBUG=3) # full invariant checking
Original file line number Diff line number Diff line change @@ -516,11 +516,13 @@ static void mi_process_done(void) {
516516 FlsFree (mi_fls_key ); // call thread-done on all threads to prevent dangling callback pointer if statically linked with a DLL; Issue #208
517517 #endif
518518
519- #if (MI_DEBUG != 0 ) || !defined(MI_SHARED_LIB )
520- // free all memory if possible on process exit. This is not needed for a stand-alone process
521- // but should be done if mimalloc is statically linked into another shared library which
522- // is repeatedly loaded/unloaded, see issue #281.
523- mi_collect (true /* force */ );
519+ #ifndef MI_SKIP_COLLECT_ON_EXIT
520+ #if (MI_DEBUG != 0 ) || !defined(MI_SHARED_LIB )
521+ // free all memory if possible on process exit. This is not needed for a stand-alone process
522+ // but should be done if mimalloc is statically linked into another shared library which
523+ // is repeatedly loaded/unloaded, see issue #281.
524+ mi_collect (true /* force */ );
525+ #endif
524526 #endif
525527
526528 if (mi_option_is_enabled (mi_option_show_stats ) || mi_option_is_enabled (mi_option_verbose )) {
You can’t perform that action at this time.
0 commit comments