pool 是相同分组(大小) block 的集合。一般,pool的大小为4kb(内存分页的大小),这主要是为了方便处理内存的fragmentation。如果一个对象被回收了,内存管理器可以再次利用这部分内存存储其他合适大小的对象。pool的结构如下:
1 2 3 4 5 6 7 8 9 10 11 12
/* Pool for small blocks. */ structpool_header { union { block *_padding; uint count; } ref; /* number of allocated blocks */ block *freeblock; /* pool's free list head */ structpool_header *nextpool;/* next pool of this size class */ structpool_header *prevpool;/* previous pool "" */ uint arenaindex; /* index into arenas of base adr */ uint szidx; /* block size class index */ uint nextoffset; /* bytes to virgin block */ uint maxnextoffset; /* largest valid nextoffset */ };
# arenas allocated total = 167 # arenas reclaimed = 69 # arenas highwater mark = 98 # arenas allocated current = 98 98 arenas * 262144 bytes/arena = 25,690,112
# bytes in allocated blocks = 23,843,888 # bytes in available blocks = 323,536 236 unused pools * 4096 bytes = 966,656 # bytes lost to pool headers = 289,728 # bytes lost to quantization = 266,304 # bytes lost to arena alignment = 0 Total = 25,690,112
3 free PyCFunctionObjects * 48 bytes each = 144 27 free PyDictObjects * 48 bytes each = 1,296 7 free PyFloatObjects * 24 bytes each = 168 5 free PyFrameObjects * 368 bytes each = 1,840 72 free PyListObjects * 40 bytes each = 2,880 31 free PyMethodObjects * 40 bytes each = 1,240 102 free 1-sized PyTupleObjects * 32 bytes each = 3,264 1998 free 2-sized PyTupleObjects * 40 bytes each = 79,920 128 free 3-sized PyTupleObjects * 48 bytes each = 6,144 4 free 4-sized PyTupleObjects * 56 bytes each = 224 25 free 5-sized PyTupleObjects * 64 bytes each = 1,600 25 free 6-sized PyTupleObjects * 72 bytes each = 1,800 3 free 7-sized PyTupleObjects * 80 bytes each = 240 1 free 8-sized PyTupleObjects * 88 bytes each = 88 0 free 9-sized PyTupleObjects * 96 bytes each = 0 0 free 10-sized PyTupleObjects * 104 bytes each = 0 0 free 11-sized PyTupleObjects * 112 bytes each = 0 0 free 12-sized PyTupleObjects * 120 bytes each = 0 0 free 13-sized PyTupleObjects * 128 bytes each = 0 0 free 14-sized PyTupleObjects * 136 bytes each = 0 0 free 15-sized PyTupleObjects * 144 bytes each = 0 1 free 16-sized PyTupleObjects * 152 bytes each = 152 0 free 17-sized PyTupleObjects * 160 bytes each = 0 1 free 18-sized PyTupleObjects * 168 bytes each = 168 0 free 19-sized PyTupleObjects * 176 bytes each = 0