Skip to content

Commit 2c95ca4

Browse files
committed
wip: census reports the growing region base
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 80f0c0e commit 2c95ca4

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/foundation/mem.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,7 @@ bool cbm_mem_win_census(cbm_mem_win_census_t *out) {
746746
out->committed_private += mbi.RegionSize;
747747
if (mbi.RegionSize > out->largest_private_region) {
748748
out->largest_private_region = mbi.RegionSize;
749+
out->largest_private_base = mbi.BaseAddress;
749750
}
750751
if (mbi.RegionSize >= (size_t)CBM_SZ_1K * CBM_SZ_1K) {
751752
out->private_regions_1mb++;
@@ -827,6 +828,7 @@ void cbm_mem_census_log(const char *tag) {
827828
char rss_kb[CBM_SZ_32];
828829
char biggest_kb[CBM_SZ_32];
829830
char regions[CBM_SZ_32];
831+
char base[CBM_SZ_32];
830832
char big_regions[CBM_SZ_32];
831833
char heaps[CBM_SZ_32];
832834
(void)snprintf(priv_kb, sizeof(priv_kb), "%zu", census.committed_private / CBM_SZ_1K);
@@ -837,6 +839,7 @@ void cbm_mem_census_log(const char *tag) {
837839
(void)snprintf(biggest_kb, sizeof(biggest_kb), "%zu",
838840
census.largest_private_region / CBM_SZ_1K);
839841
(void)snprintf(regions, sizeof(regions), "%u", census.regions);
842+
(void)snprintf(base, sizeof(base), "%p", census.largest_private_base);
840843
(void)snprintf(big_regions, sizeof(big_regions), "%u", census.private_regions_1mb);
841844
(void)snprintf(heaps, sizeof(heaps), "%u", census.heap_walk_ok ? census.crt_heap_count : 0);
842845
char dc_calls[CBM_SZ_32];
@@ -859,5 +862,5 @@ void cbm_mem_census_log(const char *tag) {
859862
"crt_busy_kb", busy_kb, "mapped_kb", mapped_kb, "rss_kb", rss_kb, "biggest_kb",
860863
biggest_kb, "regions", regions, "big_regions", big_regions, "heaps", heaps,
861864
"decommit_calls", dc_calls, "decommit_fails", dc_fail, "decommit_err", dc_err,
862-
"decommit_mb", dc_mb);
865+
"decommit_mb", dc_mb, "biggest_base", base);
863866
}

src/foundation/mem.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,10 @@ typedef struct {
238238
* rather than many leaked blocks — a different bug with a different fix. */
239239
size_t largest_private_region;
240240
unsigned private_regions_1mb;
241+
/* Base of that region: a base that stays put while the size climbs proves
242+
* ONE allocation growing, and lets it be matched against the allocator's
243+
* arena addresses to name the owner. */
244+
void *largest_private_base;
241245
bool heap_walk_ok; /* false → crt_* are unknown, not zero */
242246
} cbm_mem_win_census_t;
243247

0 commit comments

Comments
 (0)