Page 1 of 1

Where's all my Memory Going??

PostPosted: Nov 11, 2003 @ 11:45pm
by gevans2000
I'm currently testing my game which will (hopefully) shortly be released on the Smartphone platform. While I have been testing it I have been trying to reduce the memory overhead it causes.

At the moment my game appears to use about 2.5Mb of memory. (I have yet to work out how to measure the memory overhead accurately - any advice welcome.)
This is not an unreasonable amount but it seems a little bit more than many commercial games already out on smartphone.

My first port of call was obviously this forum and I have read that changing the colour depth of PNG images can help. So I did this, changing every single image in my game from the standard 16M/24bit format that PaintShopPro saves them to, to 256Col/8bit.

The file sizes generally reduced (except for really small ones where the palette info obviously has taken up a large percentage of the file size) but the memory overhead seemed to remain absolutely the same.

I have to say I can't quite work out where this 2.5Mb has come from. I have about 70 CGapiSurfaces which are defined as global variables and are on the Stack (is this sensible?). Any surfaces which will not be used in the game again - such as intro splash screens etc - are freed by calling CGapiSurface(0,(DWORD)0,0).

The largest structure I have is a LEVEL struct. Sizeof reports that this is about 50000 bytes - so that seems ok. This is created on the heap using the new operator.

Apart from a few global DWORDs etc the only other major thing I have is a lookup table for sine and cosine values - so thats 2 arrays of doubles (should I be using doubles?) of size 360.

So thats about it. I don't profess in any way to be an expert C++ programmer so I could be making many elementary mistakes - hence all my little questions in brackets!!

If anybody has any general advice for me I would be eternally grateful. I realize what I've written is not particularly detailed but you guys all seem to be pretty clever. (My Mum always used to say that flattery will get you nowhere/everywhere!!)

One more question - in the GapiDraw docs it says a CGapiSurface takes up 64 bytes of memory. Why does sizeof(CGapiSurface) report that it's size is 300?

Anyway, thanks in advance for any help.

PostPosted: Nov 12, 2003 @ 12:47am
by muff
I believe (but may be wrong) that ALL surfaces that are create under GapiDraw are either 16 bit without alpha or 24 with alpha

this is for performance reasons, so that blits dont have to lookup every pixel's real colour in a palette before doing the actual blit

but what this also means is that despite reducing all your graphics down to 8 bit, they are stored on 16 bit surfaces in the game

if you are including the graphics in the exe, then you are also increasing the memory that the game is using

I would also suggest loading and unloading the surfaces as you need them, only holding in memory the ones you are actually needing at the time

PostPosted: Nov 12, 2003 @ 1:10am
by ppcStudios

PostPosted: Nov 12, 2003 @ 7:56am
by Johan

PostPosted: Nov 12, 2003 @ 8:04am
by StarFury
Don't know if this is of help, some talk of memory requirements at graphic load time:


PostPosted: Nov 12, 2003 @ 4:28pm
by gevans2000

PostPosted: Nov 12, 2003 @ 7:40pm
by gevans2000

PostPosted: Nov 20, 2003 @ 1:26pm
by Johan

PostPosted: Nov 20, 2003 @ 6:48pm
by gevans2000