Systematic Gaming

August 26, 2008

Memory Management: Summary

Filed under: game programming, memory management — Tags: , — systematicgaming @ 2:59 am

This series hasn’t been much more than a quick over of the memory management issues facing console game development. Hopefully it’s been informative, but keep in mind it’s only an introduction and was fairly light on many of the nitty-gritty implementations details.

To wrap up this series here’s a few quick topics that deserve mentioning, as well as some links to some suggested reading.


August 25, 2008

Memory Management: Budgets, Tracking and Profiling

Filed under: game programming, memory management — Tags: , — systematicgaming @ 2:16 am

The last few entries in this series mostly focused on memory allocation. However allocation is only one part of memory management. To create a complete memory management system we need to do a lot more than allocate and free blocks of memory. We need to look at memory as a system wide resource. This involves

  • budgeting memory for the various game sub-systems
  • tracking memory use, to ensure budgets are honoured and memory doesn’t leak
  • profiling memory use to look for worst case spots in or program and trend memory usage over time

We’ll look into how we can enhance the allocation interface we’ve designed to help accomplish these goals. As well, we’ll see how these features aid us in managing memory system-wide.


August 19, 2008

Memory Management: Design

Filed under: game programming, memory management — Tags: , , — systematicgaming @ 12:29 pm

We’ve reviewed the different types of memory in part one and looked at issues specific to consoles in part two. Now we’re ready to start designing our own memory manager. Lets review our requirements:

  • Our memory manager must be fast and efficient. We don’t want to waste CPU cycles or extra bytes of RAM managing memory.
  • We need to allow memory to be allocated with arbitrary alignment.
  • We need to support managing multiple physical memory heaps as well as the ability to support both internal and external heap managers.

These are the main requirements we have above and beyond the basic functionality of allocating and releasing memory.


August 15, 2008

Memory Management: Consoles

Filed under: game programming, memory management — Tags: , , — systematicgaming @ 9:23 am

In part one we described the main types of memory. This time we’ll take a look at the memory management issues specific to consoles, or issues that are at least more prevalent in console game programming. The key differences between your regular PC and consoles are:

  • No virtual memory, which means once you’re out of memory, you’re out of memory. No swap file is going to save you on a console. Also, this makes memory fragmentation a serious concern.
  • Multiple physical memory types. On the PC you have RAM and video RAM, but you have a video driver that manages it for you, not so on consoles.
  • Memory alignment is also a problem on consoles. The x86 CPU is very forgiving. However console CPUs are generally stricter. Alignment is also very important for performance.

Now let’s take a look at these issues and others in more detail.


August 7, 2008

Memory Management: Overview of Memory

Filed under: game programming, memory management — Tags: , , — systematicgaming @ 2:19 pm

Before we can really delve into the design of a memory management system we need to have a solid understanding of memory. In this post we’ll go over different types of memory and look at how they are used in your average program. We’ll also take a look at the main issues faced with each memory type, such as lifetime, scope and problems such as fragmentation.

Disclaimer: You’ll see some code samples in the following article, they’re in pseudo-C, not compilable or even compliant. They’re included for illustration and discussion purposes.


August 5, 2008

Memory Management: Introduction

Filed under: game programming, memory management — Tags: , , — systematicgaming @ 2:16 pm

Memory management is a large part of systems programming for games. Especially on consoles where memory is a limited resource.

The main problem with memory is that there’s never enough. Modern consoles (like the Xbox 360 and PS3) have about 512MB of memory. This might seem like a lot compared to the 32MB of the PS2, but really isn’t that great compared to a PC, or the requirements of modern games. Additionally, consoles don’t generally support virtual memory, a feature of PCs which let the operating system use the hard disk as additional RAM when needed. The end result is that console games have many extra constraints and must take over the burden of managing their own memory more closely than normal PC applications.

Over the next few posts we will examine the basic memory management issues faced with console programming. In the process we will examine the goals and design of a modern game memory management system. The focus will be on how we manage memory within the complexities of a modern game development environment and how to make the best use of the limited resources of consoles.

Part One: Overview of Memory – A look at different memory types and how they are handled by compilers and applications.

Part Two: Consoles – What’s so special about consoles? We’ll look at special considerations needed for console games.

Part Three: Design – We’ll create a high level design of a memory allocation system.

Part Four: Budgets, Tracking and Profiling – So we can allocate memory, what else do we need?

Part Five: Summary – Wrapping up the series, we’ll also go over some more advanced topics for future consideration.

Blog at