Optimizing memory
We discussed how to profile and optimize two pieces of hardware—the CPU and GPU—but there is another piece of hardware that plays a key role in our game—RAM. This is the place where we put all of our game’s data. Games can be memory-intensive applications, and unlike several other applications, they are constantly executing code, so we need to be especially careful about that. The problem is that if we consume too much memory, we risk slowing down our game performance due to more costly memory accesses, or even making our game crash on non-PC platforms, like mobile or even consoles.
In this section, we will examine the following memory optimization concepts:
- Memory allocation and the garbage collector
- Using the Memory Profiler
Let’s start discussing how memory allocation works and what role garbage collection plays here.
Memory allocation and the garbage collector
Each time we instantiate an...