モバイルアプリケーションによって割り当てられたメモリサイズとステータスを取得します

当用到LruCache的时候可以用memoryClass/8 分配给缓存大小
 ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
        //获取Android设备限定的一个应用程序占用的内存限制;
        int memoryClass = manager.getMemoryClass();

        //获取运行期间,内存的使用情况
        Runtime runtime = Runtime.getRuntime();
        //当前程序在当前时间,整个分配的内存空间,这个空间可以增加,有虚拟机自己来处理
        long totalMemory = runtime.totalMemory();
        //当前程序在当前时间,虚拟机分配的内存中可用的内存空间尺寸
        long freeMemory = runtime.freeMemory();

        textView.setText("限定内存" + memoryClass + "MB totalMemory" + totalMemory + "free memory=" + freeMemory);

おすすめ

転載: blog.csdn.net/sinat_35541927/article/details/52955194
おすすめ