Sign in to follow this  
origil

When is a lot of RAM too much?

Recommended Posts

I'm currently in the programming phase of a 2D scrolling platformer and am stuck in the map structure where the problem is a lot of RAM being taken up by the map. I'll present the structure first: 100*100 tiles, in which each tile contains about 4 classes called CObject. Each CObject takes up about 30 bytes. This leading to an easy 1.2 MB, and this calculation excludes 'enemy objects' and possibly other map data. My main question is, is this too much in RAM for a map on a single player game? I've read many articles dealing with RAM and performance to death, but do today's computers with a minimum of 128 MB RAM still have such problems with 2-4 MB sized maps? If only 48 tiles are accessed each frame interval would I still have a performance problem? I realize there are many articles regarding this topic but they are usually outdated or contradicting. Keystrokes are appreciated in advance.

Share this post


Link to post
Share on other sites
yes. 1-2MB is a small amount of data. The best answer to your question is: "it's too much memory when you discover through profiling that you are being slowed down because memory is being paged out to disk"

Generally what you do is figure out what the min-spec machine for a game is. Then you create memory budgets for the game: i.e. we want our whole game to fit in 256MB of RAM, then you divide that between AI/geometry/animation data/sound data/etc/etc. Therefore, you are using too much memory for your level when you exceed the relatively arbirtarily decided upon memory budget.

For what sounds like a hobby project i wouldn't worry about it until you discover that it's a problem

-me

Share this post


Link to post
Share on other sites
It depends on your target systems. A rule of thumb is to use up to half of the installed RAM. So if you wish it to run ok on systems with 256 MB RAM, keep your memory usage below 128 MB. The latest high-end games can use over 512 MB of RAM, so you need 1 GB to keep things fluent (reverse reasoning).

Either way, 2-4 MB is definitely tiny. It's good to always keep an eye on memory usage, but don't put any special effort into it until you're reaching half the capacity of your target system.

Share this post


Link to post
Share on other sites
Yup, sounds reasonable.
It's also too early for me to analyze the market regarding the quantity of computers having less than 128MB RAM.
No idea which direction this game will be taking yet.
Thanks again,
Ori

Share this post


Link to post
Share on other sites
Also, keep in mind that the "Memory Usage" reported by programs like Task Manager is probably far more than the literal number of bytes of memory your program needs. Typically, the OS will allocate extra memory space as much as possible for efficiency. (You can see this in action by manually choking the available memory on the machine - watch the memory usage of various programs drop sharply.)

Basically, the OS knows that (chances are) your program will make many allocations repeatedly, not just one. So in order to handle this, when you request, say, 20KB of memory, Windows may actually set aside several MB. The next time you ask for 20KB, it's a fast operation, since the memory is already (sort of) allocated. This is a pretty common optimization for memory allocators.


Palidine pretty much nailed it - don't worry too much about memory consumption unless you start noticing your program thrashing the system with swapping to disk.

Share this post


Link to post
Share on other sites
All new computers bought here (in Finland) during the last two years or so have at least 512 MB RAM, because that has long been the sweet spot regarding the price/performance ratio. The point is slowly shifting towards 1GB, and in mid-range professional machines 1.5-2GB is very common.

I wouldn't bother supporting 128MB systems, as even Windows XP is quite slow with that amount of memory. Also note that as of July 2006, XP is the only consumer operating system supported by Microsoft before Vista is launched.

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