Warning Before Max Texture Memory Exceeds

Hi,

Is there anyway to pop out a warning (and stop image loading) before the texture memory is exceeded (which causes the app to crash) ?

In my app, i am allowing the user to select and load images (from the device’s photo gallery), and the selected images will appear on screen (full res). Each image will take 5MB to 20MB of texture memory (depending on the photo size).  I used 'system.getInfo( “textureMemoryUsed” ) to check.

I guess I can make the images smaller, but I was hoping that a ‘limiter’ can be shown. If I know the memory is about to exceed, i could stop loading the image and then showing an alert/warning to the user.

Thanks

You can use a listener of memory warning but I think it only works on iOS and I don’t know if you would be able to stop a image from being loaded, and I don’t even think that is necessary. When you load an image, it is downsampled to the maxTexture supported for each object.

Example, when I load an image from the photo Album, my Galaxy S1 downsamples the image to 2048. Here is the log:

05-02 11:09:00.878: V/Corona(16211): Downsampling image file '/data/data/com.redbeachgames.cutmypuzzle/cache/Caches/camerashot1399054131.jpg' to fit max pixel size of 2048. 05-02 11:09:00.914: V/Corona(16211): Downsampling image file '/data/data/com.redbeachgames.cutmypuzzle/cache/Caches/camerashot1399054131.jpg' to fit max pixel size of 2048.

So, you wouldn’t have to worry about 1 image being too large. You should worry of having too many images loaded, that would definitively make your app goes out of memory. 

You can use a listener of memory warning but I think it only works on iOS and I don’t know if you would be able to stop a image from being loaded, and I don’t even think that is necessary. When you load an image, it is downsampled to the maxTexture supported for each object.

Example, when I load an image from the photo Album, my Galaxy S1 downsamples the image to 2048. Here is the log:

05-02 11:09:00.878: V/Corona(16211): Downsampling image file '/data/data/com.redbeachgames.cutmypuzzle/cache/Caches/camerashot1399054131.jpg' to fit max pixel size of 2048. 05-02 11:09:00.914: V/Corona(16211): Downsampling image file '/data/data/com.redbeachgames.cutmypuzzle/cache/Caches/camerashot1399054131.jpg' to fit max pixel size of 2048.

So, you wouldn’t have to worry about 1 image being too large. You should worry of having too many images loaded, that would definitively make your app goes out of memory.