Game Engine Architecture

(Ben Green) #1

394 9. Tools for Debugging and Development


than using DirectX, but at least you have complete knowledge of what’s
going on.


  1. Allocators come in diff erent fl avors. Many games make use of specialized
    allocators for various purposes. For example, the Uncharted: Drake’s
    Fortune engine has a global heap for general-purpose allocations, a spe-
    cial heap for managing the memory created by game objects as they
    spawn into the game world and are destroyed, a level-loading heap for
    data that is streamed into memory during gameplay, a stack allocator
    for single-frame allocations (the stack is cleared automatically every
    frame), an allocator for video RAM, and a debug memory heap used only
    for allocations that will not be needed in the fi nal shipping game. Each
    of these allocators grabs a large hunk of memory when the game starts
    up and then manages that memory block itself. If we were to track all
    the calls to new and delete, we’d see one new for each of these six al-
    locators and that’s all. To get any useful information, we really need
    to track all of the allocations within each of these allocators’ memory
    blocks.


Most professional game teams expend a signifi cant amount of eff ort on
creating in-engine memory-tracking tools that provide accurate and detailed
information. The resulting tools usually provide their output in a variety of
forms. For example, the engine might produce a detailed dump of all memory
allocations made by the game during a specifi c period of time. The data might
include high water marks for each memory allocator or each game system,
indicating the maximum amount of physical RAM required by each. Some
engines also provide heads-up displays of memory usage while the game is

Figure 9.15. Tabular memory statistics from the Uncharted 2: Among Thieves engine.
Free download pdf