Android 获取应用可用内存

int M = 1024*1024;
Runtime r = Runtime.getRuntime();
 
Log.d("==tag==", "最大可用内存:" + r.maxMemory() / M + "M");
Log.d("==tag==", "当前可用内存:" + r.totalMemory() / M + "M");
Log.d("==tag==", "当前空闲内存:" + r.freeMemory() / M + "M");
Log.d("==tag==", "当前已使用内存:" + (r.totalMemory() - r.freeMemory()) / M + "M");
long traceMemory = (r.maxMemory() - (r.totalMemory() - r.freeMemory())) / M;
Log.i("==tag==", "剩余可用内存: " + traceMemory);

你可能感兴趣的:(Android 获取应用可用内存)