mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-01 09:14:38 +03:00
use subproc_main for final statistics output to avoid dereferencing the heap
This commit is contained in:
parent
7c7ecf096f
commit
08b64e71a7
4 changed files with 7 additions and 4 deletions
|
@ -239,6 +239,7 @@ void _mi_heap_page_reclaim(mi_heap_t* heap, mi_page_t* page);
|
||||||
// "stats.c"
|
// "stats.c"
|
||||||
void _mi_stats_init(void);
|
void _mi_stats_init(void);
|
||||||
void _mi_stats_done(mi_stats_t* stats);
|
void _mi_stats_done(mi_stats_t* stats);
|
||||||
|
void _mi_stats_print(mi_stats_t* stats, mi_output_fun* out, void* arg) mi_attr_noexcept;
|
||||||
void _mi_stats_merge_thread(mi_tld_t* tld);
|
void _mi_stats_merge_thread(mi_tld_t* tld);
|
||||||
void _mi_stats_merge_from(mi_stats_t* to, mi_stats_t* from);
|
void _mi_stats_merge_from(mi_stats_t* to, mi_stats_t* from);
|
||||||
mi_msecs_t _mi_clock_now(void);
|
mi_msecs_t _mi_clock_now(void);
|
||||||
|
|
|
@ -784,7 +784,7 @@ void mi_cdecl _mi_process_done(void) {
|
||||||
//_mi_page_map_unsafe_destroy(_mi_subproc_main());
|
//_mi_page_map_unsafe_destroy(_mi_subproc_main());
|
||||||
|
|
||||||
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)) {
|
||||||
mi_stats_print(NULL);
|
_mi_stats_print(&_mi_subproc_main()->stats, NULL, NULL); // use always main subproc at process exit to avoid dereferencing the heap (as it may be destroyed by now)
|
||||||
}
|
}
|
||||||
_mi_allocator_done();
|
_mi_allocator_done();
|
||||||
_mi_verbose_message("process done: 0x%zx\n", tld_main.thread_id);
|
_mi_verbose_message("process done: 0x%zx\n", tld_main.thread_id);
|
||||||
|
|
|
@ -405,8 +405,10 @@ void mi_register_output(mi_output_fun* out, void* arg) mi_attr_noexcept {
|
||||||
// add stderr to the delayed output after the module is loaded
|
// add stderr to the delayed output after the module is loaded
|
||||||
static void mi_add_stderr_output(void) {
|
static void mi_add_stderr_output(void) {
|
||||||
mi_assert_internal(mi_out_default == NULL);
|
mi_assert_internal(mi_out_default == NULL);
|
||||||
mi_out_buf_flush(&mi_out_stderr, false, NULL); // flush current contents to stderr
|
if (mi_out_default==NULL) {
|
||||||
mi_out_default = &mi_out_buf_stderr; // and add stderr to the delayed output
|
mi_out_buf_flush(&mi_out_stderr, false, NULL); // flush current contents to stderr
|
||||||
|
mi_out_default = &mi_out_buf_stderr; // and add stderr to the delayed output
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------
|
// --------------------------------------------------------
|
||||||
|
|
|
@ -310,7 +310,7 @@ static void mi_cdecl mi_buffered_out(const char* msg, void* arg) {
|
||||||
// Print statistics
|
// Print statistics
|
||||||
//------------------------------------------------------------
|
//------------------------------------------------------------
|
||||||
|
|
||||||
static void _mi_stats_print(mi_stats_t* stats, mi_output_fun* out0, void* arg0) mi_attr_noexcept {
|
void _mi_stats_print(mi_stats_t* stats, mi_output_fun* out0, void* arg0) mi_attr_noexcept {
|
||||||
// wrap the output function to be line buffered
|
// wrap the output function to be line buffered
|
||||||
char buf[256]; _mi_memzero_var(buf);
|
char buf[256]; _mi_memzero_var(buf);
|
||||||
buffered_t buffer = { out0, arg0, NULL, 0, 255 };
|
buffered_t buffer = { out0, arg0, NULL, 0, 255 };
|
||||||
|
|
Loading…
Add table
Reference in a new issue