@@ -3027,12 +3027,6 @@ _PyObject_DebugMallocStats(FILE *out)
3027
3027
(void )printone (out , "# arenas reclaimed" , ntimes_arena_allocated - narenas );
3028
3028
(void )printone (out , "# arenas highwater mark" , narenas_highwater );
3029
3029
(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
-
3036
3030
3037
3031
PyOS_snprintf (buf , sizeof (buf ),
3038
3032
"%zu arenas * %d bytes/arena" ,
@@ -3041,6 +3035,7 @@ _PyObject_DebugMallocStats(FILE *out)
3041
3035
3042
3036
fputc ('\n' , out );
3043
3037
3038
+ /* Account for what all of those arena bytes are being used for. */
3044
3039
total = printone (out , "# bytes in allocated blocks" , allocated_bytes );
3045
3040
total += printone (out , "# bytes in available blocks" , available_bytes );
3046
3041
@@ -3051,16 +3046,26 @@ _PyObject_DebugMallocStats(FILE *out)
3051
3046
total += printone (out , "# bytes lost to pool headers" , pool_header_bytes );
3052
3047
total += printone (out , "# bytes lost to quantization" , quantization );
3053
3048
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 );
3056
3058
#endif
3059
+ total = printone (out , "# bytes lost to arena map root" , sizeof (arena_map_root ));
3057
3060
#ifdef USE_INTERIOR_NODES
3058
3061
total += printone (out , "# bytes lost to arena map mid" ,
3059
3062
sizeof (arena_map_mid_t ) * arena_map_mid_count );
3060
3063
total += printone (out , "# bytes lost to arena map bot" ,
3061
3064
sizeof (arena_map_bot_t ) * arena_map_bot_count );
3062
- #endif
3063
3065
(void )printone (out , "Total" , total );
3066
+ #endif
3067
+ #endif
3068
+
3064
3069
return 1 ;
3065
3070
}
3066
3071
0 commit comments