Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get total RAM size of a device?

Tags:

android

ram

size

I want to get full RAM size of a device. memoryInfo.getTotalPss() returns 0. There is not function for get total RAM size in ActivityManager.MemoryInfo.

How to do this?

like image 401
BOOMik Avatar asked Sep 10 '11 19:09

BOOMik


People also ask

How do you calculate total RAM?

Here's how: Press Ctrl + Shift + Esc to launch Task Manager. Or, right-click the Taskbar and select Task Manager. Select the Performance tab to see current RAM usage displayed in the Memory box, and total RAM capacity listed under Physical Memory.

What is the total size of RAM?

Press the Windows key , type Properties, and then press Enter . In the System Properties window, the Installed memory (RAM) entry displays the total amount of RAM installed in the computer. For example, in the picture below, there is 4 GB of memory installed in the computer.

How do I find my hard drive RAM size?

Right click the My Computer icon on the Windows Desktop. Select Properties. The amount of RAM is displayed next to the CPU speed.

How can I check RAM size in CMD?

Open Start. Search for Command Prompt, right-click the top result, and select the Run as administrator option. Type the following command to determine the total amount of RAM installed on the computer and press Enter: wmic computersystem get totalphysicalmemory.


1 Answers

As of API level 16 you can now use the totalMem property of the MemoryInfo class.

Like this:

ActivityManager actManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo(); actManager.getMemoryInfo(memInfo); long totalMemory = memInfo.totalMem; 

Api level 15 and lower still requires to use the unix command as shown in cweiske's answer.

like image 57
Leon Lucardie Avatar answered Oct 04 '22 19:10

Leon Lucardie