@@ -3027,12 +3027,6 @@ _PyObject_DebugMallocStats(FILE *out)
30273027 (void )printone (out , "# arenas reclaimed" , ntimes_arena_allocated - narenas );
30283028 (void )printone (out , "# arenas highwater mark" , narenas_highwater );
30293029 (void )printone (out , "# arenas allocated current" , narenas );
3030- #ifdef USE_INTERIOR_NODES
3031- (void )printone (out , "# arena map mid nodes" , arena_map_mid_count );
3032- (void )printone (out , "# arena map bot nodes" , arena_map_bot_count );
3033- fputc ('\n' , out );
3034- #endif
3035-
30363030
30373031 PyOS_snprintf (buf , sizeof (buf ),
30383032 "%zu arenas * %d bytes/arena" ,
@@ -3041,6 +3035,7 @@ _PyObject_DebugMallocStats(FILE *out)
30413035
30423036 fputc ('\n' , out );
30433037
3038+ /* Account for what all of those arena bytes are being used for. */
30443039 total = printone (out , "# bytes in allocated blocks" , allocated_bytes );
30453040 total += printone (out , "# bytes in available blocks" , available_bytes );
30463041
@@ -3051,16 +3046,26 @@ _PyObject_DebugMallocStats(FILE *out)
30513046 total += printone (out , "# bytes lost to pool headers" , pool_header_bytes );
30523047 total += printone (out , "# bytes lost to quantization" , quantization );
30533048 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 ));
3049+ (void )printone (out , "Total" , total );
3050+ assert (narenas * ARENA_SIZE == total );
3051+
3052+ #if WITH_PYMALLOC_RADIX_TREE
3053+ fputs ("\narena map counts\n" , out );
3054+ #ifdef USE_INTERIOR_NODES
3055+ (void )printone (out , "# arena map mid nodes" , arena_map_mid_count );
3056+ (void )printone (out , "# arena map bot nodes" , arena_map_bot_count );
3057+ fputc ('\n' , out );
30563058#endif
3059+ total = printone (out , "# bytes lost to arena map root" , sizeof (arena_map_root ));
30573060#ifdef USE_INTERIOR_NODES
30583061 total += printone (out , "# bytes lost to arena map mid" ,
30593062 sizeof (arena_map_mid_t ) * arena_map_mid_count );
30603063 total += printone (out , "# bytes lost to arena map bot" ,
30613064 sizeof (arena_map_bot_t ) * arena_map_bot_count );
3062- #endif
30633065 (void )printone (out , "Total" , total );
3066+ #endif
3067+ #endif
3068+
30643069 return 1 ;
30653070}
30663071
0 commit comments