This allows the algorithm to easily find available space for a given block size, even across multiple different pools of the same size class. A
usedpools list tracks the status of each pool that is neither full or empty of blocks. When a given block size is requested, the algorithm checks this
usedpools list for the list of pools for the block size needed. Pools themselves may be in one of three states:
used pool has available blocks for data to be stored. A
full pool’s blocks are all allocated and contain data. An
empty pool has no data stored and can be assigned any size class for blocks when needed. Similar to
freepools list keeps track of all the pools in the
empty state, but when do empty pools actually get used? Well, assume your code needs an 8-byte chunk of memory.
If there are no pools in
usedpools of the 8-byte size class, a fresh
empty pool is initialized to store 8-byte blocks. This new pool then gets added to the
usedpools list so it can be used for future requests.
Become a Member to join the conversation.