Collect heap level stats

This commit is contained in:
liunyl 2024-01-31 08:21:22 +00:00
parent e47379461e
commit 479edc9b85
8 changed files with 69 additions and 49 deletions

View file

@ -154,8 +154,8 @@ mi_decl_export void mi_stats_reset(void) mi_attr_noexcept;
mi_decl_export void mi_stats_merge(void) mi_attr_noexcept;
mi_decl_export void mi_stats_print(void* out) mi_attr_noexcept; // backward compatibility: `out` is ignored and should be NULL
mi_decl_export void mi_stats_print_out(mi_output_fun* out, void* arg) mi_attr_noexcept;
mi_decl_export void mi_thread_stats(int64_t *allocated, int64_t *committed,
int64_t *reserved) mi_attr_noexcept;
mi_decl_export void mi_thread_stats(int64_t *allocated,
int64_t *committed) mi_attr_noexcept;
mi_decl_export void mi_process_init(void) mi_attr_noexcept;
mi_decl_export void mi_thread_init(void) mi_attr_noexcept;

View file

@ -45,8 +45,8 @@ terms of the MIT license. A copy of the license can be found in the file
// #define MI_TRACK_ASAN 1
// #define MI_TRACK_ETW 1
// Define MI_STAT as 1 to maintain statistics; set it to 2 to have detailed statistics (but costs some performance).
#define MI_STAT 1
// Define MI_STAT as 1 to maintain statistics; set it to 2 to have detailed
// statistics (but costs some performance). #define MI_STAT 1
// Define MI_SECURE to enable security mitigations
// #define MI_SECURE 1 // guard page around metadata
@ -512,6 +512,8 @@ struct mi_heap_s {
size_t page_retired_max; // largest retired index into the `pages` array.
mi_heap_t* next; // list of heaps per thread
bool no_reclaim; // `true` if this heap should not reclaim abandoned pages
uint64_t allocated;
uint64_t committed;
};