When developing video games, satisfying the platform's memory requirements is one of the most challenging tasks. In this in-depth feature, veteran developer Jelle van der Beek maps out the memory analysis tool
created while working at Playlogic, focusing on monitoring memory use on the PC.
In this excerpt, the developer discusses to concept behind the tool, called MemAnalyze 2.0, which builds upon the tool's previous version covered in earlier Gamasutra features (part one
“We begin by intercepting all memory allocations in the game. For each allocation that is performed, metadata is saved in memory, most notably callstack information. At any moment in time the user can select to write all allocation data to file. The file serves as input for our MemAnalyze tool. The tool can analyse the data and offer multiple views on that data.
This concept has some drawbacks:
- Monitoring memory usage is limited to a single moment in time, a snapshot of the memory statistics of the game.
- Storing metadata in the application that is being monitored clutters your memory statistics. In my test environment, which is an average sized commercial game, the top of the allocation count is roughly half a million allocations. About 80.000 of those allocations were performed by operator new. The size of the metadata of an allocated block differs per block because of variable callstack lengths, but one of my tests shows that on average 126 bytes are needed per allocated block. Note that in this test 32 bit addresses were stored in the callstack. This means that approximately 77 megabytes of additional memory is needed for a memory map containing all metadata per block. If only the allocations from operator new were stored, we would need approximately 9.5 megabytes.
To remove both restrictions, we now instead send any allocation data directly over the network. A tool that runs on a PC then gathers the allocation mutations and maintains an internal memory map. This tool can then do real-time analysis on its internal memory map.
That’s actually all there is to it.”
You can now read the complete feature
, which includes an exhaustive analysis of the MemAnalyze tool, including code samples and a look ahead at what the future holds (no registration required, please feel free to link to this column from external websites).