Game Development Reference
In-Depth Information
Figure 3.1
Memory pool block.
Figure 3.2
Memory pool chunk allocated.
When a chunk of memory is destroyed, it simply returns it to the list. It may seem
like an unnecessarily complex system to use this linked list, but it ' s not. You can ' t
guarantee the order in which things will be freed, so having this linked list structure
allows you to find the next free chunk in constant time. It also allows for dealloca-
tion in constant time since the chunks are returned to the front of the list. After a
while, your nice clean array will start to look a bit messy with chunks being
requested and freed all the time. Figure 3.3 shows what your block might end up
looking like.
Figure 3.3
Memory pool usage.
Search WWH ::




Custom Search