当前位置:首页 » 安卓系统 » android获取ram

android获取ram

发布时间: 2022-08-09 14:33:59

A. android adb shell 怎么查ram

Android 中查看内存的使用情况集常用adb命令
http://blog.csdn.net/bigconvience/article/details/35553983

B. 索爱 lt15i android系统怎么查手机的 rom 和ram

设置里有储存和应用程序设置,储存是SD卡什么的。。。应用程序设置里有存储空间使用情况,有RAM查看。这样查很不方便,建议你去下载个安卓优化大师,CPU,RAM,ROM等等全在一起

C. 请问android模拟器如何增加RAM

很简单,点开始菜单,点运行,输入cmd然后回车,cd 到android sdk里面的tools目录中然后输入如下命令:emulator -memory 512 -partition-size 512 -avd **** 注释:1:memroy 512是设置ram为 512 M 2:-partition-size 512 是设置rom为512 M 3:-avd **** 是指你需要加载的虚拟设备,其中的****就是虚拟设备的名字如果你在新建虚拟设备时取的名字是android,ram为512M,rom为1024M的话,参考命令如下:emulator -memory 512 -partition-size 1024 -avd android如有不明白的,可以向我咨询!

D. 安卓开发怎样获取RAM大小

获取RAM总大小
[mw_shl_code=java,true]private long readTotalSize() {
try {
long memTotal = 0;
FileInputStream is = new FileInputStream("/proc/meminfo");
int len = is.read(mBuffer);
is.close();
final int BUFLEN = mBuffer.length;
for (int i=0; i<len && memTotal == 0; i++) {
if (matchText(mBuffer, i, "MemTotal")) {
i += 8;
memTotal = extractMemValue(mBuffer, i);
break;
}
while (i < BUFLEN && mBuffer != '\n') {
i++;
}
}
return memTotal;
} catch (java.io.FileNotFoundException e) {
} catch (java.io.IOException e) {
}
return 0;
}[/mw_shl_code]

获取剩余大小
[mw_shl_code=java,true]private long readAvailMem() {
try {
long memFree = 0;
long memCached = 0;
FileInputStream is = new FileInputStream("/proc/meminfo");
int len = is.read(mBuffer);
is.close();
final int BUFLEN = mBuffer.length;
for (int i=0; i<len && (memFree == 0 || memCached == 0); i++) {
if (matchText(mBuffer, i, "MemFree")) {
i += 7;
memFree = extractMemValue(mBuffer, i);
} else if (matchText(mBuffer, i, "Cached")) {
i += 6;
memCached = extractMemValue(mBuffer, i);
}
while (i < BUFLEN && mBuffer != '\n') {
i++;
}
}
return memFree + memCached;
} catch (java.io.FileNotFoundException e) {
} catch (java.io.IOException e) {
}
return 0;
}[/mw_shl_code]

里面的两个方法
[mw_shl_code=java,true]private long extractMemValue(byte[] buffer, int index) {
while (index < buffer.length && buffer[index] != '\n') {
if (buffer[index] >= '0' && buffer[index] <= '9') {
int start = index;
index++;
while (index < buffer.length && buffer[index] >= '0'
&& buffer[index] <= '9') {
index++;
}
String str = new String(buffer, 0, start, index-start);
return ((long)Integer.parseInt(str)) * 1024;
}
index++;
}
return 0;
}[/mw_shl_code]

[mw_shl_code=java,true]private boolean matchText(byte[] buffer, int index, String text) {
int N = text.length();
if ((index+N) >= buffer.length) {
return false;
}
for (int i=0; i<N; i++) {
if (buffer[index+i] != text.charAt(i)) {
return false;
}
}
return true;
}[/mw_shl_code]

要是还不能解决?

你来我们群里说吧

这里是开发者互相学习交流的

有大神

让他们给你解释你的疑问 q un号: 188168 040

E. 如何获取 Android 设备的CPU核数,时钟频率以及内存大小

Device Year Class 的主要功能是根据 CPU核数、时钟频率 以及 内存大小 对设备进行分级。代码很简单,只包含两个类:

DeviceInfo-> 获取设备参数,
YearClass-> 根据参数进行分级。
下表是 Facebook 公司提供的分级标准,其中Year栏表示分级结果。

Year Cores Clock RAM
2008 1 528MHz 192MB
2009 n/a 600MHz 290MB
2010 n/a 1.0GHz 512MB
2011 2 1.2GHz 1GB
2012 4 1.5GHz 1.5GB
2013 n/a 2.0GHz 2GB
2014 n/a >2GHz >2GB
关于输出年份的计算方法可以参考源码,本文只把一些比较常用的功能抽取出来做一个简要介绍。

获取 CPU 核数
我们都知道,Linux 中的设备都是以文件的形式存在,CPU 也不例外,因此 CPU 的文件个数就等价与核数。

Android 的 CPU 设备文件位于/sys/devices/system/cpu/目录,文件名的的格式为cpu\d+。

?
1
2
3
4
5
6
7
8
9
10
root@generic_x86_64:/sys/devices/system/cpu # ls <b>cpu0</b> cpufreq
cpuidle
kernel_max
modalias
offline
online
possible
power
present
uevent
统计一下文件个数便可以获得 CPU 核数。

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
public static int getNumberOfCPUCores() {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
// Gingerbread doesn't support giving a single application access to both cores, but a
// handful of devices (Atrix 4G and Droid X2 for example) were released with a al-core
// chipset and Gingerbread; that can let an app in the background run without impacting
// the foreground application. But for our purposes, it makes them single core.
return 1;
}
int cores;
try {
cores = new File("/sys/devices/system/cpu/").listFiles(CPU_FILTER).length;
} catch (SecurityException e) {
cores = DEVICEINFO_UNKNOWN;
} catch (NullPointerException e) {
cores = DEVICEINFO_UNKNOWN;
}
return cores;
}

private static final FileFilter CPU_FILTER = new FileFilter() {
@Override
public boolean accept(File pathname) {
String path = pathname.getName();
//regex is slow, so checking char by char.
if (path.startsWith("cpu")) {
for (int i = 3; i < path.length(); i++) {
if (path.charAt(i) < '0' || path.charAt(i) > '9') {
return false;
}
}
return true;
}
return false;
}
};
回到顶部
获取时钟频率
获取时钟频率需要读取系统文件 -/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq或者/proc/cpuinfo。

我的 Android 模拟器中并没有cpuinfo_max_freq文件,因此只能读取/proc/cpuinfo。

/proc/cpuinfo包含了很多 cpu 数据。

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 70
model name : Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
stepping : 1
cpu MHz : 0.000
cache size : 1024 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 4
wp : yes
代码如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
public static int getCPUMaxFreqKHz() {
int maxFreq = DEVICEINFO_UNKNOWN;
try {
for (int i = 0; i < getNumberOfCPUCores(); i++) {
String filename =
"/sys/devices/system/cpu/cpu" + i + "/cpufreq/cpuinfo_max_freq";
File cpuInfoMaxFreqFile = new File(filename);
if (cpuInfoMaxFreqFile.exists()) {
byte[] buffer = new byte[128];
FileInputStream stream = new FileInputStream(cpuInfoMaxFreqFile);
try {
stream.read(buffer);
int endIndex = 0;
//Trim the first number out of the byte buffer.
while (buffer[endIndex] >= '0' && buffer[endIndex] <= '9'
&& endIndex < buffer.length) endIndex++;
String str = new String(buffer, 0, endIndex);
Integer freqBound = Integer.parseInt(str);
if (freqBound > maxFreq) maxFreq = freqBound;
} catch (NumberFormatException e) {
//Fall through and use /proc/cpuinfo.
} finally {
stream.close();
}
}
}
if (maxFreq == DEVICEINFO_UNKNOWN) {
FileInputStream stream = new FileInputStream("/proc/cpuinfo");
try {
int freqBound = parseFileForValue("cpu MHz", stream);
freqBound *= 1000; //MHz -> kHz
if (freqBound > maxFreq) maxFreq = freqBound;
} finally {
stream.close();
}
}
} catch (IOException e) {
maxFreq = DEVICEINFO_UNKNOWN; //Fall through and return unknown.
}
return maxFreq;
}
回到顶部
获取内存大小
如果 SDK 版本大于等于JELLY_BEAN,可以通过ActivityManager来获取内从大小。

?
1
2
3
ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
ActivityManager am = (ActivityManager) c.getSystemService(Context.ACTIVITY_SERVICE);
am.getMemoryInfo(memInfo);
如果版本低于JELLY_BEAN,则只能读取系统文件了。

?
1
2
FileInputStream stream = new FileInputStream("/proc/meminfo");
totalMem = parseFileForValue("MemTotal", stream);
完整代码如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static long getTotalMemory(Context c) {
// memInfo.totalMem not supported in pre-Jelly Bean APIs.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
ActivityManager am = (ActivityManager) c.getSystemService(Context.ACTIVITY_SERVICE);
am.getMemoryInfo(memInfo);
if (memInfo != null) {
return memInfo.totalMem;
} else {
return DEVICEINFO_UNKNOWN;
}
} else {
long totalMem = DEVICEINFO_UNKNOWN;
try {
FileInputStream stream = new FileInputStream("/proc/meminfo");
try {
totalMem = parseFileForValue("MemTotal", stream);
totalMem *= 1024;
} finally {
stream.close();
}
} catch (IOException e) {
}
return totalMem;
}
}

F. android系统的手机配置一般都提到RAM+ROM组合,这里的ROM是什么意思是只读吗把软件安装到内存是何解

1、 ROM 是 ROM image(只读内存镜像)的简称,常用于手机定制系统玩家的圈子中。 一般手机刷机的过程,就是将只读内存镜像(ROM image)写入只读内存(ROM)的过程。
常见的 ROM image 有 img、zip 等格式,前者通常用 fastboot 程序通过数据线刷入(线刷),后者通常用 recovery 模式从 sd刷入(卡刷),固 img 镜像也被称为线刷包,zip 镜像也被称为卡刷包。 国内的定制系统开发者,经常会陷入自己的产品究竟是应该称为 OS 还是 UI 的争论,为了避免此类争论和表示谦虚,会自称为 ROM。很多定制系统玩家也会统一将定制系统称为 ROM。
2、把软件安装到内存,其实是软件要运行,需要占用内存,所以软件是要安装在内存。

G. 安卓系统的手机怎么查看RAM和ROM有多大

查看rom:

  1. 打开系统设置

  2. 点击存储

  3. 向下拖动找到内存设备(有的叫内部存储)。

  4. 总容量显示了当前的内置模拟sd的容量。

关于这个值和rom容量的对应关系:

显示0~2.5g,rom为4g

显示2.5~6.5g,rom为8g

显示6.5~14g,rom为16g

显示14~26g,rom为32g

显示38~58g,rom为64g

显示更多为128g(目前最大容量)。


查看ram:

  1. 打开系统设置

  2. 点击应用

  3. 向左滑动屏幕切换到“正在运行”页面

  4. 屏幕下方条状示意图显示了已用、可用ram,加起来结果再加10%就是理论ram值了。


其它的方法:

可以下载手机管家或验机、跑分软件,里面也有详细配置信息。

H. 怎样增加安卓手机的虚拟运行内存RAM 怎么刷谢谢!

朋友,其实不必过于在意android系统的运存大小,系统会帮你管理,android不是windows,剩余内存大不是就会快,我也是android用户,以前总用什么es任务管理器清理小z(Desire Z)后台的程序,而且用得是CM的系统,总保持230M+的运存,可是并没有什么体现在使用上,现在用得带sense的rom,开着动态壁纸,有时候后台就76M的空余内存,但是一点也不卡,有的时候看会到130M+(很大一部分内存都被sense界面占用了)依然不卡,android系统的任务管理和资源分配做得不错,不必过于在意运存,我还真不相信有压榨干RAM的android应用呢,一个进程占用30M、40M了不起了,就算是比较大型的游戏占用100M+系统也能很好的管理RAM,这时候他会自动释放后台程序,合理配置资源,用了那种清理RAM的软件反倒会打乱这机制导致系统变卡。而楼主想用swapper来增加内存,说实话,这就像windows的虚拟内存一样,不一样的是虚拟内存基于硬盘,而swap基于储存卡,储存卡的读写是有次数的,这样频繁的读写还会减少储存卡寿命。楼主不要迷信RAM大会增加运行速度。望对楼主有用。

热点内容
ftp上传进度 发布:2024-04-30 23:11:23 浏览:882
python网页抓取 发布:2024-04-30 23:11:02 浏览:885
虚拟机linux无线 发布:2024-04-30 22:53:49 浏览:750
忘了信用卡密码怎么办 发布:2024-04-30 22:47:43 浏览:722
python继承和多态 发布:2024-04-30 22:47:15 浏览:951
魅族15改存储 发布:2024-04-30 22:39:43 浏览:93
存储过程添加数据到hdfs 发布:2024-04-30 22:18:34 浏览:718
如何快速解压很多文件手机版 发布:2024-04-30 21:45:06 浏览:435
redhatpython安装 发布:2024-04-30 21:37:31 浏览:355
长城大屏导航初始密码多少 发布:2024-04-30 21:37:18 浏览:181