Game Development Reference
In-Depth Information
In this output you can see the three allocated 4-byte objects and each of the start and next
addresses in each allocation header. The output is updated again after deleting the second object.
Destroyed
0x00870320
0x0087032C
0x00870340
4
0x00870340
0x0087034C
0x00870350
4
0x00870350
0x00000000
0x00000000
0
The first allocated object now points to the third and the second allocated object has been removed
from the heap. A fourth object is allocated just to see what would happen.
Constructed
0x00870320
0x0087032C
0x00870340
4
0x00870340
0x0087034C
0x00870350
4
0x00870350
0x0087035C
0x00870360
4
0x00870360
0x00000000
0x00000000
0
At this point pSimple1 is stored at address 0x0087032C , pSimple2 is at 0x0087035C , and pSimple3 is at
0x0087034C . The program then ends by deleting each allocated object one by one.
Despite the problems that would prevent you from using this memory manager in production code,
it does serve as a useful example of how a heap operates. Some method of tracking allocations is
used so that the memory management system can tell which memory is in use and which memory is
free to be allocated.
Search WWH ::




Custom Search