Look at the CPU usage activity for the Unity game. This is a good starting point and provides a clear indicator if the game is CPU bound. Also, perform call stack walking where you see the functions that the game itself called. By seeing the functions that the game is calling, you can see if any unexpected Windows APIs are called as a result. This could lead to unexpected game performance issues.
- [Narrator] Let's look at the game's memory usage by clicking on the memory category drop down arrow. From the charts listed, the one we are most interested in is the VirtualAlloc Commit LiftTimes chart. Let's click on that chart and drag and drop it over to the right hand side. Let's then maximize it by clicking on the maximize button to the top right of the chart. Each line on the graph shows the memory usage over time for each process on that machine. If we hover our mouse over the top line we can see that it belongs to the Factory Escape game. Now, let's shift our focus to the factory process in the table below.
Let's then right click on it, and from the popup menu select Filter to Selection. Let's then right click on the process column header, and from that popup menu select Commit Stack. This will bring up that additional column, and what this column will show us is the calls made to request virtual memory and what is leading to the game's memory usage. Let's then click on the drop down arrow next to Factory Escape. And this will expand the list of the commit stack. The function we are looking for is a D3D11 allocate buffer call and D3D11 resource map calls which leads to the graphics module which is IGD10IMUD32, and we can inspect the call stack by clicking on the scroll bar at the very bottom and dragging it to the right.
As before we see these PDB not found messages, and if we keep scrolling, we eventually get to this D3D11Device Context Map. Followed by the D3D11 Resource map call, and then the graphics module, IGD10IMUD32. Let's keep scrolling. And then we can see this Allocate Constant Buffer call. Create Allocation call.
And if we keep scrolling we get to more Create Allocation calls. So this is the call stack leading to the virtual memory allocations. What we can gather from this commit stack is that the game is using a resource that is causing virtual memory allocations to be made, and these virtual memory allocations are resulting in the game's 10 megabyte memory usage. From our 3D pipeline discussion, we know that textures are a resource that can have high memory usage, and this memory usage increases when multi-sample anti aliasing is turned on. So, this gives us a good starting point for memory usage optimization.
Knowing that it's a texture resource that is causing the memory usage indicated by the D3D11 resource map call. If we want to lower the memory usage, we will need to look at how the texturing is being performed, and especially look at the multi-sample anti aliasing.