activityManager = activityManager == null ? ContextCompat.getSystemService(mContext, ActivityManager.class):activityManager; ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo(); activityManager.getMemoryInfo(memoryInfo); long totalMemory = memoryInfo.totalMem; Debug.MemoryInfo[] memoryInfos = activityManager.getProcessMemoryInfo(new int[] {Process.myPid()}); long myProcessMemory = memoryInfos[0].getTotalPrivateDirty() * 1024; Timber.d("系统内存信息:%s 当前应用内存(getTotalPrivateDirty):%s", totalMemory, myProcessMemory);
获取的信息如下:
系统内存信息:7978627072 当前应用内存(getTotalPrivateDirty):181772288
Android Profiler监听如下:
使用的是目前官网最新的SuperMap iMoblie 11i 64位包,内存占用貌似不是很高