ActivityManager mActivityManager = (ActivityManager)mApplication.getSystemService(ACTIVITY_SERVICE);
int memory = mActivityManager.getMemoryClass();
float totalMemory = (float) (Runtime.getRuntime().totalMemory() * 1.0/ (1024 * 1024));
float freeMemory = (float) (Runtime.getRuntime().freeMemory() * 1.0/ (1024 * 1024));
Log.e("内存","最大分配内存:"+memory+" 当前分配的总内存:"+totalMemory+" 剩余内存:"+freeMemory);
获得当前手机的内存状态
最新推荐文章于 2020-03-23 22:10:48 发布