安卓 获取RAM
<火山程序 类型 = "通常" 版本 = 1 />方法 获取RAM <公开 类型 = "长整数[]" 注释 = "数组0 总内存" 注释 = "数组1 空闲内存" 注释 = "数组2 已使用的内存">
{
@ long totalMemory = Runtime.getRuntime().totalMemory(); // 当前虚拟机中的总内存
@ long freeMemory = Runtime.getRuntime().freeMemory(); // 当前虚拟机中的空闲内存
@ long usedMemory = totalMemory - freeMemory; // 当前虚拟机中已使用的内存
变量 总内存 <类型 = 长整数>
变量 空闲内存 <类型 = 长整数>
变量 已使用的内存 <类型 = 长整数>
变量 RAM数据 <类型 = "长整数 ">
@ @<总内存>=totalMemory;
@ @<空闲内存>=freeMemory;
@ @<已使用的内存>=usedMemory;
RAM数据 = 总内存
RAM数据 = 空闲内存
RAM数据 = 已使用的内存
返回 (RAM数据)
}
<火山程序 类型 = "通常" 版本 = 1 />
方法 获取RAM <公开 类型 = "长整数[]" 注释 = "数组0 总内存\r" 注释 = "数组1 空闲内存\r" 注释 = "数组2 已使用的内存">
{
变量 RAM数据 <类型 = "长整数 ">
@ @<RAM数据 > = Runtime.getRuntime().totalMemory(); // 当前虚拟机中的总内存
@ @<RAM数据 > = Runtime.getRuntime().freeMemory(); // 当前虚拟机中的空闲内存
@ @<RAM数据 > = @<RAM数据 > - @<RAM数据 >; // 当前虚拟机中已使用的内存
返回 (RAM数据)
}
这样可行吗? 编译试试??
页:
[1]