一、Debug和ActivityManager的相关方法:
public void printMemoryInfo() {
String tag = "APPActivity";
final ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
ActivityManager.MemoryInfo info = new ActivityManager.MemoryInfo();
activityManager.getMemoryInfo(info);
Log.i(tag, "系统剩余内存:" + (info.availMem >> 10) + "k");
Log.i(tag, "系统是否处于低内存运行:" + info.lowMemory);
Log.i(tag, "当系统剩余内存低于" + (info.threshold >> 10) + "时就看成低内存运行");
Log.i(tag, "NativeHeapSizeTotal:" + (Debug.getNativeHeapSize() >> 10));
Log.i(tag, "NativeAllocatedHeapSize:" + (Debug.getNativeHeapAllocatedSize() >> 10));
Log.i(tag, "NativeAllocatedFree:" + (Debug.getNativeHeapFreeSize() >> 10));
Debug.MemoryInfo memoryInfo = new Debug.MemoryInfo();
Debug.getMemoryInfo(memoryInfo);
Log.i(tag, "memoryInfo.dalvikPrivateDirty:" + (memoryInfo.dalvikPrivateDirty));
Log.i(tag, "memoryInfo.dalvikPss:" + (memoryInfo.dalvikPss ));
Log.i(tag, "memoryInfo.dalvikSharedDirty:" + (memoryInfo.dalvik