Memory cost for using same graphic multiple times?

I remember reading somewhere that creating another copy of an image that’s already being displayed doesn’t add to the amount of texture memory used.

I’m making a 2D side scroller and my background is made up of five or so interchangeable 320 x 320 images that I randomly select at the start of each level. Each level can be up to 20 background images wide.

Right now, I just create all the background images at the start of each level and draw all but one of them off screen. This works fine, but I still worry about memory use,

Should I instead be creating them just before I need them and then deleting them once they’ve scrolled off the screen? (My game can scroll in both directions)

Thanks

Have you measured your memory use?  No need to worry about it if you haven’t looked yet.  In fact, if you are concerned about memory usage, you should start measuring and see what actions cost what memory (system and video).

If you don’t know how to measure this already, you can get a very basic meter here:

Save this: 

http://raw.githubusercontent.com/roaminggamer/RG_FreeStuff/master/AskEd/2016/07/camera_hiccups/basic_meters.lua

in the file basic_meters.lua

Usage:

local meters = require "basic\_meters" meters.create\_fps() meters.create\_mem()

Hi @gmplayer,

Will you be using dynamic image selection for larger “retina” devices, or is 320x320 the absolute maximum of any of these tiles on any device? If you intend to use really large, sharp background tiles for something like the iPad Air or iPad Pro, that would mean tiles of potentially 1280x1280. While a device like that can easily handle that size, you still might want to pre-load textures so that, when they display during fast scrolling of the level, there is absolutely no “skip” involved from the texture being re-loaded into texture memory on-the-fly.

There are a few different ways to deal with pre-loading textures. One simple, one more advanced. It just depends on your needs basically. :slight_smile:

Best regards,

Brent

System memory used is about 0.5 Mb

Texture memory used is about 1.0 Mb

On my biggest levels.

I’m kinda new to cellphones, but that seems pretty small  :slight_smile:

What’s a safe amount of memory to use on games you want to work on phones a couple years old and newer?

Thanks

If you’re using any images at all, 1mb of texture memory is way too small. A single 512x512 would be a 1mb texture. Of course more smaller images… i.e 256 64x64’s.

What would be a ballpark number to stay under for memory and texture memory usage?

This is device dependent of course. But for apps that would use 1X graphics, staying under 50mb might be reasonable. For 2X graphics, keeping things under 100-150mb and for 4X devices, a couple of hundred megabytes. 

Rob

Thanks,

Any limits on how far offscreen I can draw things?

Could I draw something 10,000 pixels to the right or left of the current screen?

  1. No.

  2. Yes.

Have you measured your memory use?  No need to worry about it if you haven’t looked yet.  In fact, if you are concerned about memory usage, you should start measuring and see what actions cost what memory (system and video).

If you don’t know how to measure this already, you can get a very basic meter here:

Save this: 

http://raw.githubusercontent.com/roaminggamer/RG_FreeStuff/master/AskEd/2016/07/camera_hiccups/basic_meters.lua

in the file basic_meters.lua

Usage:

local meters = require "basic\_meters" meters.create\_fps() meters.create\_mem()

Hi @gmplayer,

Will you be using dynamic image selection for larger “retina” devices, or is 320x320 the absolute maximum of any of these tiles on any device? If you intend to use really large, sharp background tiles for something like the iPad Air or iPad Pro, that would mean tiles of potentially 1280x1280. While a device like that can easily handle that size, you still might want to pre-load textures so that, when they display during fast scrolling of the level, there is absolutely no “skip” involved from the texture being re-loaded into texture memory on-the-fly.

There are a few different ways to deal with pre-loading textures. One simple, one more advanced. It just depends on your needs basically. :slight_smile:

Best regards,

Brent

System memory used is about 0.5 Mb

Texture memory used is about 1.0 Mb

On my biggest levels.

I’m kinda new to cellphones, but that seems pretty small  :slight_smile:

What’s a safe amount of memory to use on games you want to work on phones a couple years old and newer?

Thanks

If you’re using any images at all, 1mb of texture memory is way too small. A single 512x512 would be a 1mb texture. Of course more smaller images… i.e 256 64x64’s.

What would be a ballpark number to stay under for memory and texture memory usage?

This is device dependent of course. But for apps that would use 1X graphics, staying under 50mb might be reasonable. For 2X graphics, keeping things under 100-150mb and for 4X devices, a couple of hundred megabytes. 

Rob

Thanks,

Any limits on how far offscreen I can draw things?

Could I draw something 10,000 pixels to the right or left of the current screen?

  1. No.

  2. Yes.