Reduce RAM usage

11 replies [Last post]
by: mraaz
Status: Offline
Joined: 2011-12-05
Points: 350

How to reduce RAM Usage in our game?
am using 20-30 images .each image having 28kb size
and 128*128 res..but now our game takes 95MB ram
in our Devices(mobiles)..can any one help me out ?

My Icf settings is here:

{OS=ANDROID}
[s3e]
Memsize6=20728640
DispFixRot=2
{}

[S3E]
MemSize=20728640
DispFixRot=2
{[RESMANAGER] ResBuildStyle == sw}

{}
MemSizeDebug=4000000 # Needs to be this large to support building 2430 data set (due to PVRing of large textures)
MemSizeDebugDevice= 2000000
WinWidth=1024
WinHeight=768
WinResizable=1

by: Jayfreck
Status: Offline
Joined: 2011-05-18
Points: 780
is 28kb the filesize of the

is 28kb the filesize of the images?
by my calculations, each 128x128 image will be using 64k of memory in 32bit colour, though that still doesnt add up to anywhere near 95mb

what are you doing with the images once loaded?

by: mraaz
Status: Offline
Joined: 2011-12-05
Points: 350
Thanks for the reply Jayfreck

Thanks for the reply Jayfreck..,
each image having 28kb,128*128 and 32-bit..

what are you doing with the images once loaded?
just displaying on the mobile screen and has some moving functionality

by: waheyluggage
Status: Offline
Joined: 2011-07-22
Points: 2810
Are the two lines that do...

Are the two lines that do...

Memsize6=20728640
MemSize=20728640

Allocating two lots of 20mb? That'll be 40mb of ram usage not including your vram usage.

by: mraaz
Status: Offline
Joined: 2011-12-05
Points: 350
ok.. i removed Memsize6 from

ok.. i removed Memsize6 from my .icf file..but our game RAM usage is not reduced..it showing same 90kb in our mobiles.what can i do now..??
please suggest me..
{OS=ANDROID}
[s3e]
#Memsize6=20728640
DispFixRot=2
{}

by: waheyluggage
Status: Offline
Joined: 2011-07-22
Points: 2810
Oh, that would just remove

Oh, that would just remove 20mb from your Android build if I'm reading that properly. It wouldn't show up under iOS anyway.

Do you have mipmapping on? That would use a bit extra, not enough to account for all that ram. Created any render targets?

And when you run it under the emulator and enable metrics is it all vram that's being used? and just a small heap?

by: mraaz
Status: Offline
Joined: 2011-12-05
Points: 350
no ..we are not using any

no ..we are not using any mipmapping concept..and no render targets also..

by: waheyluggage
Status: Offline
Joined: 2011-07-22
Points: 2810
Hmm, not sure then. Any

Hmm, not sure then. Any large fonts being used?

If you run it under simulator, enable metrics, display metrics, what values do you get for...

Studio->MemBuckets->System->Size
Any other MemBuckets there?
IwGL->Objects->Textures
IwGX->TexturesTotalSize

As an example for my game which is a pretty graphics heavy 2d game. I get...

Studio->MemBuckets->System->Size = 28914560 (~28mb)
No other buckets than SystemDebug
IwGL->ObjectTextures = 55
IwGX->TexturesTotalSize = 36080640 (~35mb).

I'm loading about 8 lots of 1024x1024 sprite sheets. Some are loaded as 16bit though so that reduces a lot by half. Really my TexturesTotalSize would be about 70mb if I made them all 32bit. Still nowhere near your 95mb though.

by: mraaz
Status: Offline
Joined: 2011-12-05
Points: 350
Studio->MemBuckets->System-

Studio->MemBuckets->System->Size = 20914560 (~28mb)
No other buckets than SystemDebug
IwGL->ObjectTextures = 120(max)
IwGX->TexturesTotalSize = 62849778 (Max).

we are using 32-bit images mostly..and our game size(Assets) is 28mb.and our game takes 90mb RAM on mobiles to run.?
So is there any methode to reduce RAM Usage ??because low-end devices not supported that much..

by: Jayfreck
Status: Offline
Joined: 2011-05-18
Points: 780
something is clearly wrong

something is clearly wrong there, because my last game with four 512x512 textures loaded is only using around 4mb.

IwGL->ObjectTextures = 120
i believe this is the number of textures currently loaded, which is a lot more than the 28-30 you originally mentioned. In my game, this matches IwGX->Textures uploaded (my game has 6 on the menu screen). what have you got there?

It seems like your textures are being loaded multiple times each

by: waheyluggage
Status: Offline
Joined: 2011-07-22
Points: 2810
Yeah, your 120 looks quite

Yeah, your 120 looks quite high. It definitely appears to be the number of textures you have loaded, you're using ~62mb if vram. As Jayfreck sats, check you're not loading the images multiple times.

When you say your game asset size is 28mb, how have you calculated that? If it's the size of the PNG\JPG's then remember they get decompressed. So if you had a PNG that's 1024x1024 but 1 colour it's space on disk will be tiny, like a few KB, but when it's in vram it will be 4mb.

by: Lester-Madden
Status: Offline
Joined: 2012-05-08
Points: 3260
one of our engineers recently

one of our engineers recently wrote a sample to help track down were memory is being used:

To help identify if and where excessive texture memory is being used refer to the attached modified version of the IwUIHelloWorld example. The example includes a debug menu showing the approximate texture memory used by the program. The menu can be navigated using the direction keys and toggled with F6. Within the "IwResManager" menu you can see all textures loaded as resources.

Integrating this debug menu into your application should be straightforward. It should be just a matter of transferring the definitions of IwGxMetricsGL, IwGxMetricsGLGet, CIwMenuItemGLMetrics, DebugCreateMainMenu and adding the code related to creating and setting up the CIwMenuManager singleton.

The sample might be useful in helping you track down the cause

Latest Posts

Latest Comments

Top Contributors

  • Chris D : 27,010
  • MonRoyals : 26,970
  • Salman : 26,720
  • Jez Hammond : 20,130
  • pjan : 11,150
  • gjw : 10,350
  • Paolo Oliverio : 9,640
  • Beaker_2 : 8,390
  • Kite : 8,210
  • bluescrn : 7,810