• Stephen Brown

I'm losing my memory!!

It's been a while since I looked into the memory usage of this game and boy has it got a bit out of control! Once again the procedural nature of the system can mean it all gets a bit out of control as you have to monitor where your memory usage is going.


I've had a lot of users with 1Gb devices telling me that they cannot get past a certain point because the U.S.A. track fails to load (it just crashes with an out of memory error.) So I promised that I would sort it out for this update. I love that people with iPhone6 devices and similar android spec devices are buying and playing this game, so it is only fair that I continue to support them!


The trees generate their imposter detail on the fly, this is because all the trees are procedurally generated. This means that every tree "definition" that is created by the engine, needs to auto generate the imposters for rendering in the distance, it wouldn't be ideal to have an artist create all this data would it! Imposters are used to save rendering full scale tree models in the distance. The basics are, render the tree at 16 or so angles, render the lighting texture (so you can light them in the distance correctly), generate mip maps, and then draw each tree as a single flat plane in the distance. You do this for each tree definition you have.


So with the above in mind, a quick bit of debugging showed that the trees were allocating a nice 150Mb of imposter detail on the GPU, which on iOS and android is doubled too. This is because the texture data has to be stored on the CPU just in case the user minimises the app, and the renderer needs to resend the data to the GPU when it is restored. I could rebuild the imposters when the user restores by rendering it all again, but it takes a bit of time (usually done in the loading). Plus most devices have plenty of memory for this! (Except that is the iPhone6!)


What I've done then is simply reduced the imposter texture size from 2048x2048 -> 1024x1024 on low end devices, I've also limited the number of tree definitions in a race to 1, rather than 10 or more. so basically this memory usage is fully scaled down!


The shot below shows a comparison between the two modes, you can't really tell the difference (the car textures are blurry for sure) but the trees are not so bad. Also on an iPhone6, the screen is so small you don't notice :)


222 views

© 2020 Brownmonster Limited.

  • Buy for Nintendo Switch
  • Buy on Google Play Store
  • Buy on the Apple App Store
  • Discord
  • Follow us on Instagram
  • Follow us on Twitter
  • Follow us on Facebook