Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GPU memory limit for saving textures on Android & iOS devices

I am creating an Android app based on Open GL ES 3.0 which has to cater to wide range of devices.

Due to certain requirement in my app, I have to retain lot of image data on the RAM while my app is running. Since, android phones have a limit to per application CPU memory usage or heap memory size limit, I decided to retain my required image data as textures on GPU memory while my app runs.

My texture size is 1024x1024. Saving textures & displaying them back again when required all works fine for the implementation part of it.

But, soon I figured that the GPU memory has close limits as well (as it seems). I am able save only 1024x1024x50 approximate number of textures on a Sony XPeria Z5. 1024x1024x70 textures on another Sony XPeria series. 1024x1024x90 on a Huawei P8 and so on.

Also, I found that there is a limit to textures/GPU memory on iOS devices too. I am not able to save more that 1024x1024x90 textures on an iPhone 6+ !!

The numbers here are not accurate but quite close. My objective of putting up this question is to get an understanding of how much GPU memory is allowed to an application on android devices.

Does GPU memory allowed to an android app related to the CPU memory somehow as this link here indicates ?

Android apps can request for large heap by a property declared in Manifest. Likewise, Is there some way I can request for more GPU memory for my app ?

Are textures really stored on GPU memory or a part of it also stored on CPU memory ?

Any information related to GPU memory limit on iOS devices along with android will be helpful.

like image 869
TheWaterProgrammer Avatar asked Mar 27 '17 18:03

TheWaterProgrammer


People also ask

What is the maximum memory limit given for each process or application in Android?

16 MB is the maximum memory limit given to any given android application. Some second generation phones will return 24 MB of memory for each process or even more.

How to check memory usage in Android?

Open your Apps list and tap the ""Settings"" app. Select ""Device care"" or ""Device maintenance"" on the menu—the name varies by model. Now, tap ""Memory"" to view the total amount of RAM in your phone or tablet, as well as RAM usage per app.


1 Answers

I think that all the devices you're concerned with have unified memory, which means you needn't worry about the distinction between GPU and CPU memory. From your point of view, it's best to see it as the same pool of RAM.

Android apps can request for large heap by a property declared in Manifest. Likewise, Is there some way I can request for more GPU memory for my app ?

Large heap refers to Java allocations. If you're writing native code (lots of apps that target iOS and Android have the majority of their code in C++) then it might not make much difference.

You can see how much memory different iOS devices have here.

For Android, you can look here to see the compatibility definitions. For example, non-watch devices supporting Marshmallow have at least 512MB.

You can work out how much memory your textures need, assuming 32-bit 8888 format and no mipmaps, each texture is 1024*1024*4bytes=4MB (please update the question if those assumptions are wrong!). The Sony XPeria Z5 with 50 of those is dying at approx 200MB. The Huawei P8 and iPhone6+ are dying at 360MB.

You shouldn't expect to be able to use anywhere near all of the RAM on a smartphone. There's an OS and other apps that need to run, and there's no storage based virtual memory like you'd see on desktop OSs. As a rule of thumb, you can expect to use about 30%-50% of the system's RAM before the OS shuts down your app. iOS definitely, and I believe Android too, send your app warnings when your memory usage is getting too high.

The back-of-the-envelope maths works out about right on iPhone6+ (1GB RAM, you get to use 360MB), but the Sony XPeria Z5 and Huawei P8 both have an enormous 3GB of RAM. TBH, I have no idea why you're able to use so little of it.

EDIT: Also, running in a debugger adds a significant memory overhead, but I don't feel it could explain the missing GBs on those Android devices.

like image 72
Columbo Avatar answered Oct 08 '22 11:10

Columbo