Skip to content

Commit b41a77a

Browse files
committed
Improve sys._debugmallocstats() output.
1 parent e0924e6 commit b41a77a

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Objects/obmalloc.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,8 +1391,8 @@ typedef struct arena_map_top {
13911391
#ifdef USE_INTERIOR_NODES
13921392
static arena_map_top_t arena_map_root;
13931393
/* accounting for number of used interior nodes */
1394-
static int arena_map_top_count;
13951394
static int arena_map_mid_count;
1395+
static int arena_map_bot_count;
13961396
#else
13971397
static arena_map_bot_t arena_map_root;
13981398
#endif
@@ -1415,7 +1415,7 @@ arena_map_get(block *p, int create)
14151415
return NULL;
14161416
}
14171417
arena_map_root.ptrs[i1] = n;
1418-
arena_map_top_count++;
1418+
arena_map_mid_count++;
14191419
}
14201420
int i2 = MAP_MID_INDEX(p);
14211421
if (arena_map_root.ptrs[i1]->ptrs[i2] == NULL) {
@@ -1427,7 +1427,7 @@ arena_map_get(block *p, int create)
14271427
return NULL;
14281428
}
14291429
arena_map_root.ptrs[i1]->ptrs[i2] = n;
1430-
arena_map_mid_count++;
1430+
arena_map_bot_count++;
14311431
}
14321432
return arena_map_root.ptrs[i1]->ptrs[i2];
14331433
#else
@@ -3028,8 +3028,8 @@ _PyObject_DebugMallocStats(FILE *out)
30283028
(void)printone(out, "# arenas highwater mark", narenas_highwater);
30293029
(void)printone(out, "# arenas allocated current", narenas);
30303030
#ifdef USE_INTERIOR_NODES
3031-
(void)printone(out, "# arena map top nodes", arena_map_top_count);
30323031
(void)printone(out, "# arena map mid nodes", arena_map_mid_count);
3032+
(void)printone(out, "# arena map bot nodes", arena_map_bot_count);
30333033
fputc('\n', out);
30343034
#endif
30353035

@@ -3051,6 +3051,15 @@ _PyObject_DebugMallocStats(FILE *out)
30513051
total += printone(out, "# bytes lost to pool headers", pool_header_bytes);
30523052
total += printone(out, "# bytes lost to quantization", quantization);
30533053
total += printone(out, "# bytes lost to arena alignment", arena_alignment);
3054+
#ifdef WITH_PYMALLOC_RADIX_TREE
3055+
total += printone(out, "# bytes lost to arena map root", sizeof(arena_map_root));
3056+
#endif
3057+
#ifdef USE_INTERIOR_NODES
3058+
total += printone(out, "# bytes lost to arena map mid",
3059+
sizeof(arena_map_mid_t) * arena_map_mid_count);
3060+
total += printone(out, "# bytes lost to arena map bot",
3061+
sizeof(arena_map_bot_t) * arena_map_bot_count);
3062+
#endif
30543063
(void)printone(out, "Total", total);
30553064
return 1;
30563065
}

0 commit comments

Comments
 (0)