How can mobile games use so little ram?

0 favourites
  • 11 posts
From the Asset Store
Use your jumps wisely and timely to get over all obstacles!
  • Hey,

    After optimizing my construct game for 2 weeks, I managed to go from 2GB to 1GB of ram usage by downscaling the ~200 images in total significantly (Not all on one layout). They are now around 500x500, some are a bit bigger.

    Recently, I downloaded a bunch of games and monitored their ram/memory usage and was genuinely surprised by the result.

    Huge mobile games like Asphalt 8 or Brawlstars that are 100mb-2GB in size and display hundreds of images in one scene only take up 10-50mb in Ram.

    Do you guys know how this can be achieved and if that is also possible in Construct?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 3d can use way less memory since its based on geometry with shaders making up unique textures. You can't do that with 2d, you have to essentially prebake all those images rather than create them on the fly.

    You have to apply similar methods of reusing things if you want to get anywhere near that kind of ram usage.

    construct.net/en/blogs/construct-official-blog-1/remember-not-waste-memory-796

  • The memory footprint of images goes up exponentially as they get larger. A 100x100 image has 10,000 pixels, while a 1000x1000 image has 1,000,000 pixels.

    Note that for mobile devices especially, even though the resolution on modern devices is as high as monitors, the dpi density is also much higher. Basically even though it is high resolution, the physical screen size is still very very small. You can use much lower resolution textures, with scaling, and it will be much harder for an eye to discern the difference on a mobile screen versus a monitor, even if both the monitor and mobile device have similar resolutions.

    To further optimize, similar texturing techniques to 3d can be done in 2d with repeating backgrounds and the canvas plugin (optionally with effects as shaders). Use the canvas plugin to draw the shape, and layered repeating backgrounds to texture large areas of it.

    Edit: As with tiled backgrounds, by extension the 9-patch object can also be used in certain situations to lower memory use significantly.

    More traditionally, 2d games make very heavy use of tilemaps to reuse a set of textures over large areas. When that is still not enough, different tilesets assets are loaded and unloaded as needed (via layouts in Construct). This is usually done when areas don't have much in common and assets can't be easily reused or shared between the two, such as different biomes.

    Note that tilemaps are not only useful for terrain. With a little creativity, they can be applied in other situations as well.

  • Thank you for your detailed answer! I have actully found 2 images hidden somewhere in my project that were actully 4000x4000 and they took up soo much memory! Also, I now destroy all other unused versions of my character (you can choose one in game) at runtime. Also, I will have a look at the Extensions you mentioned.

  • I still wonder how a game like brawlstars with a loading screen image that is 4k and

    many other high res assets can only use 4mb of ram.

  • How do you know how much VRAM Brawlstars is using? And how do you know that the loading screen image is originally 4k and not simply scaled?

    Also as Newt mentioned, Brawlstars is a 3D game. Objects are drawn at runtime, and not loaded from an image. From what I can see, many objects are simply colored in, which doesn't require a texture image at all.

  • I apologize if any of my assumptions are completely wrong ;)

    In android you can see in the settings how much ram an app is using, and I am assuming that the cpu just uses the same ram for video memory and normal one. I got the metrics from that, and it displays the amount of ram my construct game uses correctly too.

    I used APKEditor to see what kind of images are inside the game and the loading screen is a png with 4K resolution. I cant tell though if it is being downscaled or something before being displayed.

  • A single large image is not an issue, especially for a loading screen, since it wouldn't need to be kept in memory after that anyway.

  • Yes, thats true but I was just wondering how this loading screen could only use 500mb ram. People in another forum (stack overflow) told me that brawlstars is constantly unloading unused images at runtime in the menus and downscaling the images in the engine (so the loading image is downscaled). Also, brawlstars is using svg images for some icons.

    Speaking of svg, I have heard mixed things about them in construct. Some say they are great, others say they are bad for performance. Do you guys have an opinion on that?

  • Svg has to be rasterized when you show it, or at anytime you do anything to it.

    So its great, only as a static image.

  • Thank you, does this involve changing the opacity too?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)