Sign in to follow this  
russt17

How to lower RAM used by a game?

Recommended Posts

russt17    122
What steps should I take to lower the amount of RAM a game uses? I'm a beginner so please try to keep answers simple! thanks!

Share this post


Link to post
Share on other sites
ToohrVyk    1595
First, determine what parts of your game use up so much data. Then, once you've identified the heaviest parts, reduce their memory usage by finding ways to store less data (for instance, using smaller textures or maps, re-computing the data instead of storing it, or using the flyweight design pattern).

Share this post


Link to post
Share on other sites
Antheus    2409
Have you even determined that memory use is a problem for you?

If so, how, and how does it show? Task Manager is not useful for determining application's memory use.

Share this post


Link to post
Share on other sites
dashurc    236
One easy way is to reduce your texture sizes (but this might not be an option depending on how nice you want things to look). One thing to do for sure is to ensure you don't load the same texture twice. Just share the texture.

The best way to reduce memory consumption is to design for it. Just be aware of how much you're using and try to keep your modules within reason. Most non-art asset related memory is usually small in size, but if you have a pool of say 20 identical enemies and you need some sort of attribute table for a bazilion attributes, don't give each enemy an instance to this gigantic table if you can make it static and shared across the entire class. That's not to say you should be worried about every byte here and there (although you might want to be more careful with regards to data being sent over a network).

So...yeah... Just keep an eye out for bad data design and you should do ok.

Lastly, but just as important, you should probably not fuss too much about this unless you're actually running into a problem, or you want to release your game commercially and you're using a ridiculous amount of memory for what you're delivering. Especially if you're just learning.

Share this post


Link to post
Share on other sites
eedok    982
I got him to e-mail me his code, his problem is that he's loading the same image multiple times, in his initialization code he loads his bullet image 15 times, then in his main loop he compares the current image by reloading it then comparing the image data to the current image of a sprite, then never freeing it.


So the lesson here is you should never load an image more than once.

Share this post


Link to post
Share on other sites
Oluseyi    2103
Assuming you have taken analytical steps to determine that your game's volatile memory consumption is too high, you have a number of strategy options to reduce it. Keep in mind that, generally, memory consumption is traded against application speed.
  1. Reduce asset size, resolution and/or complexity. If your memory is being consumed by overly large or detailed assets, where a degradation in quality will only marginally affect the experience of playing the game, consider using smaller or lower-quality resources. For instance, using smaller source texture images causes them to be stretched over larger portions of geometry, but if the camera is far enough away or the quality is reduced in portions of the geometry that are rarely seen, the game experience might not change significantly.

    Similarly, you might be able to downgrade from 192kbps to 128kbps for audio samples, or employ lossy rather than lossless encodings, both of which can reduce the size of audio files appreciably.

  2. Swap to/from memory more frequently. If assets can not be reduced without adversely affecting the game experience, then consider breaking your game up into smaller chunks of gameplay, and loading the assets needed for each chunk separately. While this can reduce peak and overall memory usage, it incurs the penalty of introducing delays into the game experience as resources are loaded from disk after each checkpoint.

  3. Streaming and asynchronous loading. If you have sufficient processing power to spare, however, an alternate solution is to only load the portions of resources that are required when they are required. This requires rearchitecting your game into sectors and cross-indexing various game elements to indicate when they must be loaded from disk. It may also require storing resources in file formats modified or specially designed for partial loading - when you only need a portion of a resource from somewhere other than the start of the file.

    You can also place multiple versions of a resource in a file (and use run-time methods in conjunction), so that a smaller, low-resolution version can be quickly loaded and then higher-resolution details are put in place as the game encounter draws closer.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this