How to measure VRAM consumption on Android?
Asked Answered
H

6

14

I want to acquire Android Device VRAM size.

Is there a method for acquisition from the program?

Helbona answered 1/7, 2010 at 1:49 Comment(2)
I would like to know this as well. If there's no way to query it from the device, a list of the amount of video RAM on common devices would do as well.Friedland
To be clear, I mean the amount of RAM available for OpenGL textures, buffers, etcetera. Maybe this isn't "video RAM", per se, but "OpenGL server memory"?Friedland
D
17

Let's do some calculation using Nexus One:

Screen resolution is 480x800. So minimum required video memory size would be:
400 * 800 * 4 bytes = 1536000 bytes

Assuming that driver may (and normally should) use several buffers, we should also expect values like:

1536000 * 2 bytes = 3072000 bytes
1536000 * 3 bytes = 4608000 bytes
etc...

It would be weird to have values that are not multiple of 1536000 (or W x H x 4 in general).


After some searches on Android internals I've found this documentation :

...Android makes two requirements of the driver: a linear address space of mappable memory that it can write to directly...accessing the driver by calling open on /dev/fb0...

So I tried and take size of /dev/graphics/fb0 file (on my device there is no /dev/fb0).

But a direct approach doesn't work:

 File file = new File("/dev/graphics/fb0");
 file.length(); // ==0, doesn't work, no read access

Using next trick you can get actual size of fb0:
>adb pull /dev/graphics/fb0
1659 KB/s (4608000 bytes in 2.712s)

Video memory is ~4mb (Nexus One). Let's check if this is multiple of Nexus screen size:

4608000/1536000 = 3

It looks like a right value. And we also can say that driver uses three screen buffers.


So, as a conclusion, you can detect video memory size using adb, but you can't use this approach from your android application in runtime due to file access restrictions.

Derouen answered 26/1, 2011 at 0:29 Comment(1)
Nice investigation, thanks, but not what I was looking for. Probably I haven't been entirely clear. What I want to know is the size of the OpenGL server memory, in which we store textures, vertex buffers, etc. Anyway, if that question doesn't get answered, the bounty is yours.Friedland
Z
6

You typically do not have a dedicated "VRAM" on mobile devices. At least you don't have it with PowerVR architectures (wich totally dominate the market with their MBX and SGX cores).

That is, the OpenGL driver allocates normal RAM until you run out of it, and the more you allocate the less you have left for your application.

Zimbabwe answered 28/1, 2011 at 16:49 Comment(0)
N
4

The Android/OpenGL APIs don't offer explicit methods to read the VRAM size from a given device.

Poor man solution:
You could try to infer the VRAM size in an empiric way adding 1MB texture until you get an out of memory error from gl.glGetError().

Nerissa answered 27/1, 2011 at 12:6 Comment(0)
B
3

From your "dmesg" output u can read off the VRAM, so for my Tablet:

> [    0.000000] Machine: TDM3730 [    0.000000] Reserving 12582912
> bytes SDRAM for VRAM
> 
> 7>[    3.929962] VRAM: checking region 9f400000 3072                  
> <4>[    3.929992] Failed. Allocating 4194304 bytes for fb 0           
> <7>[    3.935333] VRAM: alloc mem type 0 size 4194304 paddr dec2bd4c  
> <7>[    3.935485] VRAM: checking region 9f400000 3072                 
> <7>[    3.935485] VRAM: found 9f400000, end a0000000                  
> <6>[    3.936584] android_usb gadget: high speed config #1: android   
> <4>[    3.960113] allocating 4194304 bytes for fb 1

or details at:

http://pastebin.com/jQSXQqHh

Braw answered 2/6, 2012 at 1:49 Comment(0)
B
1

Is simple just count how many Mb ram that from usable to real capacity of the ram, example for my lenovo a369i has 512 RAM Module, but in setting app only showing 471 Mb usable so the 41Mb left is reserved for the GPU, so the conclusion is my a369i has 41Mb vram

This method is based from shared graphics memory (wiki)

Bilge answered 1/1, 2016 at 15:21 Comment(0)
E
-2

I suspect that android.os.StatFs is what you're looking for:

http://developer.android.com/reference/android/os/StatFs.html

Endocarp answered 1/7, 2010 at 2:10 Comment(1)
I'd wager that stat has little to do with video ram size.Piscatorial

© 2022 - 2024 — McMap. All rights reserved.