memory usage in iOS and shaders

Hi guys,

I have a few issues I can’t quite figure out…

  1.  I am looking at memory allocation on iOS (android seems fine) and I am seeing 17MB texture memory and 70-80MB lua memory on device but xCode instruments is reporting 175MB memory and 825MB virtual memory? My app sometimes gets shut down for low memory in iOS.  I am using collectgarbage(“count”)/1024 for lua memory and system.getInfo(“textureMemoryUsed”)/1000000 for texture memory.  The image below is from xCode instruments, it is taken at the same time as the image in point 2

memory.jpg

  1. I’ve just started to play with shaders and they work fine on simulator(PC and Mac) and Android but fail horribly on iOS.  I say fail, but the shader itself works fine, its just all the other graphics either don’t load or load as black boxes.  The shader is basically the water effect in the sample.  the following image highlights the same code running on iOS and Android.

android_ios.jpg

Any advice would be great

Thanks

Adrian

Update, I’ve forced low resolution graphics on iPad2 and that keeps memory usage under 250MB and the app doesn’t get shut down by iOS.  What I don’t get is why the memory usage reported by lua is different to what I am seeing in instruments?

Some figures:

lua 46MB, texture 9MB but instruments shows 62MB persistent,

lua 55MB, texture 17MB but instruments shows 144MB persistent.

I am looking at all heap and VM allocations.  I’m trying to optimise for low end devices with limited RAM and I don’t understand why the reported values are so different?

Can you post your code where you’re printing your memory usage?

Hi Rob, it was in the OP.   I am using collectgarbage(“count”)/1024 for lua memory and system.getInfo(“textureMemoryUsed”)/1000000 for texture memory.

I’ve fixed the black blocks issue on iOS - not sure why it only affects iOS though.

I had this before I set the fills on the Rect (as per the pattern fill sample)

  display.setDefault( “textureWrapX”, “repeat” )

  display.setDefault( “textureWrapY”, “mirroredRepeat” )

Nowhere in the sample app or documentation did it say to reset this before loading any other graphics!  Because none of my other graphics were power of 2 they all failed to load and just gave black squares.  The fix (found by much hacking and frustration) was to reset these settings after applying the fills.

  display.setDefault( “textureWrapX”, “clampToEdge” )

  display.setDefault( “textureWrapY”, “clampToEdge” )

Personally, I think having to set and reset project-wide settings before and after adding a fill is not intuitive and certainly not atomic.  Can these not be passed as parameters to the fill then these would not affect anything else.

Update, I’ve forced low resolution graphics on iPad2 and that keeps memory usage under 250MB and the app doesn’t get shut down by iOS.  What I don’t get is why the memory usage reported by lua is different to what I am seeing in instruments?

Some figures:

lua 46MB, texture 9MB but instruments shows 62MB persistent,

lua 55MB, texture 17MB but instruments shows 144MB persistent.

I am looking at all heap and VM allocations.  I’m trying to optimise for low end devices with limited RAM and I don’t understand why the reported values are so different?

Can you post your code where you’re printing your memory usage?

Hi Rob, it was in the OP.   I am using collectgarbage(“count”)/1024 for lua memory and system.getInfo(“textureMemoryUsed”)/1000000 for texture memory.

I’ve fixed the black blocks issue on iOS - not sure why it only affects iOS though.

I had this before I set the fills on the Rect (as per the pattern fill sample)

  display.setDefault( “textureWrapX”, “repeat” )

  display.setDefault( “textureWrapY”, “mirroredRepeat” )

Nowhere in the sample app or documentation did it say to reset this before loading any other graphics!  Because none of my other graphics were power of 2 they all failed to load and just gave black squares.  The fix (found by much hacking and frustration) was to reset these settings after applying the fills.

  display.setDefault( “textureWrapX”, “clampToEdge” )

  display.setDefault( “textureWrapY”, “clampToEdge” )

Personally, I think having to set and reset project-wide settings before and after adding a fill is not intuitive and certainly not atomic.  Can these not be passed as parameters to the fill then these would not affect anything else.