LruCache大小的定义
来源:互联网 发布:阿尔法狗算法公开 编辑:程序博客网 时间:2024/06/04 21:41
缓存设置多少合适呢,一般情况下,设置为当前可用内存的8分之1,那么就需要先获取当前可用内存是多少,通过以下代码可以知道当前缓存的大小:
final int memClass = ((ActivityManager)getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass();
得到当前缓存的大小后,即可对缓存的大小进行设置,代码如下:
public class KaleApplication extends Application{ /** * @description * * @param context * @return 得到需要分配的缓存大小,这里用八分之一的大小来做 */ public int getMemoryCacheSize() { // Get memory class of this device, exceeding this amount will throw an // OutOfMemory exception. final int memClass = ((ActivityManager)getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass(); // Use 1/8th of the available memory for this memory cache. return 1024 * 1024 * memClass / 8; }}
本文出自 “移动平台开发” 博客,请务必保留此出处http://liuxudong1001.blog.51cto.com/10877072/1873832
阅读全文
0 0
- LruCache大小的定义
- 项目大小的定义
- 一个定义大小端的宏
- 大小端的宏定义使用
- Fortran中可变大小数组的定义
- android定义system.img的大小i
- 根据输入值定义的数组大小
- 易语言 取自定义数据类型的大小
- 重新定义oracle temp01.dbf的大小
- 易语言 取自定义数据类型的大小
- 系统大小端的头文件定义
- tomcat的LRUCache
- LruCache的终极解析
- 对lrucache的解读
- LruCache的深入解析
- LruCache源码的理解
- android的LruCache
- lruCache的用法
- android studio添加jar包及so文件问题
- 常见工具:dp与px互转,屏幕宽度与高度获取
- 超级好用的工具类:图片选取(拍照/相册)
- Error: Connection strategy not found at MongoStore 这是connect-mongo版本的问题
- Glide框架------加载图片部分
- LruCache大小的定义
- SharedPreferences保存中,数据到底存在了哪里?
- Android 6.0及以上版本定位权限开发问题
- eclipse Unable to execute dex: GC overhead limit exceeded GC overhead limit exceeded解决办法
- 开关原理图
- 简单工厂设计模式
- kindEditer富文本编辑器从前端到后台完整经验
- 自定义View详解
- 安卓app启动另外一个app