Game performance
What to check when a game starts slowly, stutters, or uses more and more memory.
If a game runs slowly, first determine where the delay occurs: loading files, executing code, or rendering frames.
We use the following panels to investigate:
- Network: which files the game loads, their sizes, and how long the downloads take.
- Performance: a recording of the page’s activity. It helps identify a slow function or measure the time spent rendering a frame.
- Memory: snapshots of objects in memory. Compare the state before opening a scene and after closing it to see which objects remain and what still refers to them.
For example, if window still holds the closed scene’s event handler, the scene may remain in memory. We examined this connection in the lesson on memory leaks. Increasing memory use alone does not prove a leak: we need to find objects that the game no longer needs but still retains.
In the interactive diagram, we will select a problem and see where to start investigating.
After changing the code, repeat the same actions on the same device and compare the results. For example: does the first scene open faster, has stuttering stopped, and have old scenes stopped accumulating in memory?