GameMaker: content and performance¶
Profiling, the VM and YYC outputs, memory and garbage collection, texture and audio groups, rooms and instances, and saving. Batching, surfaces, texture pages and shaders are in Rendering and shaders, and frame budgets and save-data versioning are in Game development.
Entries are sorted by score from 1 to 10 (criteria): 9โ10 start here or strongly recommended, 6โ8 recommended, 1โ5 further reading or conditional.
Adopted references¶
- 8 Best Practices When Programming (GameMaker Manual): local variables, arrays and data structures, collisions, texture swaps and vertex batches, particles and surfaces.
- 7 How To Optimise Your Games (GameMaker, 2024): texture groups, flushing and prefetching, dynamic textures, blend modes and batching, sound settings, and faster GML.
- 7 The Debugger and The Debug Overlay (GameMaker Manual): breakpoints, the Profiler, memory and frame-time graphs, and an in-game overlay with custom debug views.
Key rules¶
Profiling and compilation¶
- 7
GAMEMAKER-PERF-1Profile the game on every target device, during development and before and after each optimisation, with the Debugger's Profiler and the Debug Overlay. The overlay's FPS window shows the frame time against the game speed and the texture swaps and vertex batches, and the overlay also shows memory use and the garbage collector. This appliesGAMEDEV-12andGFX-3. (GameMaker Manual, The Profiler, The Debugger, The Debug Overlay: FPS) - 6
GAMEMAKER-PERF-2Test and debug on the VM, but build the release of a CPU-heavy game with YYC on the platforms that offer it, measure its performance in that build, and clear the compiler cache before every final build. YYC compiles GML to native code and can make logic-heavy games two to three times faster, while the Debugger runs your code on the VM. (GameMaker Manual, Compiling, YoYo Compiler, The Debugger)
Memory and loading¶
- 7
GAMEMAKER-PERF-3Destroy everything you create at run time that has a destroy function, such as data structures, surfaces and buffers, usually in the Clean Up event, and use arrays and structs rather than DS lists and maps. These resources aren't garbage-collected, while arrays and structs are. Leave the garbage collector on; turning it off isn't recommended. (GameMaker Manual, Garbage Collection, Data Structures, Object Events: Clean Up, gc_enable) - 7
GAMEMAKER-PERF-4Assign sprites, tile sets and fonts to texture groups by where they're used, such as one group per level and one for the menus, and keep groups that only some rooms need out of memory: make them dynamic, load them withtexturegroup_load()before they're needed, and unload them afterwards. Drawing from a dynamic group that isn't loaded loads it on the spot, which can freeze the game for a moment, so turn on explicit mode withtexturegroup_set_mode(true)to catch it. Dynamic groups aren't supported on HTML5. (GameMaker Manual, Texture Groups, Dynamic Textures, GameMaker, How To Optimise Your Games) - 6
GAMEMAKER-PERF-5Choose each sound's compression by its length and use, and put sounds that only some rooms need in audio groups that you load withaudio_group_load(). Keep short sound effects uncompressed, compress long or rarely used ones, and compress and stream music from disk. Every sound in the default audio group, except streamed ones, is loaded into memory when the game starts. (GameMaker, How To Optimise Your Games, GameMaker Manual, Audio Groups)
Rooms and instances¶
- 6
GAMEMAKER-PERF-6Build static scenery from tile layers rather than instances with sprites, and check collisions against the tile map where the level fits a grid. Tiles have a much lower processing overhead than sprites, and collision functions such asplace_meeting()accept a tile map. (GameMaker Manual, Animated Tiles, Tile Set Editor, place_meeting, Best Practices When Programming) - 5
GAMEMAKER-PERF-7If you deactivate instances outside the view, do it every few steps or when the camera moves, never every step or in a Draw event, and reactivate persistent instances at least one step before the room changes. Deactivating every step can itself cost performance, and a persistent instance that is deactivated isn't carried into the next room. (GameMaker Manual, Deactivating Instances)
Saving¶
- 7
GAMEMAKER-PERF-8Follow the manual's advice against losing saves: write each save to a new file, check it, then replace the old one, validate a save, for example with a checksum, before loading it, and keep files open only briefly. Serialise save data withjson_stringify()andjson_parse(), the JSON functions the manual recommends for new projects. This appliesGAMEDEV-10andGAMEDEV-11. On HTML5, saves go to the browser's local storage, which may hold only 1 to 5 MB. (GameMaker Manual (Beta), The File System: preventing data loss, GameMaker Manual, The File System, Guide To Using JSON)
How to enforce¶
Tools that check the key rules above automatically, in CI, the IDE or a commit hook. "Partly" means the tool covers only some of what the rule asks.
- 7 Dynamic texture groups, explicit mode: after
texturegroup_set_mode(true), an image from a dynamic texture group that wasn't loaded first isn't drawn, an error goes to the output log, and an optional fallback sprite shows where it happened, so test runs catch implicit loads. Partly checksGAMEMAKER-PERF-4.