CursorWindow: Could not allocate CursorWindow '......'of size 2097152 due to error -12.
来源:互联网 发布:怎么在淘宝出售游戏币 编辑:程序博客网 时间:2024/05/21 11:01
最近做app的时候,频繁操作数据。app在运行2个小时左右完全死掉。再想通过broadcastReciever唤醒都不行!!!!
因为得到的数据需要多个方面互通,因此选择的方式是定时修改数据库,定时查询数据库的思路。
使用service后台通过timer,timertask方式修改数据库中的数据。定时在UI查询适配数据。
我的APK处在一个绝对优秀的系统里。不会有360,腾讯管家等流氓软件强制kill。
查遍各种资料。。。方法给很多。。。还是折磨了我一个星期。。。。
我现在告诉你,这个问题的关键原因:
就是内存溢出!!!
就是内存溢出!!!
就是内存溢出!!!
不用想别的。。。。。。。。解决方式就是手动关闭cursor对象+手动回收垃圾
cursor.close();必须执行
finalize();
现在粘贴解决代码:
public List<House> findAllHouse(){ List<House> houseList=new ArrayList<>(); Cursor allHouse=null; try { allHouse = rdb.rawQuery("select * from house order by hid", null); while (allHouse.moveToNext()){ House house=new House(); house.setHid(allHouse.getInt(0)); house.setHname(allHouse.getString(1)); house.setHstate(allHouse.getString(2)); house.setHswitch(allHouse.getString(3)); house.setHzone(allHouse.getInt(4)); houseList.add(house); } }catch (Exception e){ Log.e("Exception","Exception"); }finally { allHouse.close(); try { finalize(); } catch (Throwable throwable) { throwable.printStackTrace(); } } return houseList;}
切记。。。两步必须执行。。。。。。。
不然的话。。。。今年奖金扣掉
1 0
- CursorWindow: Could not allocate CursorWindow '......'of size 2097152 due to error -12.
- [已解决]Could not allocate CursorWindow '' of size of size 2097152 due to error -12.
- 出现Could not allocate CursorWindow of size due to error -12.错误的解决方案
- Could not allocate CursorWindow size due to error -12 错误解决方法
- Could not allocate CursorWindow size due to error -12 错误解决方法
- Could not allocate CursorWindow size due to error -12 错误解决方法
- Could not allocate CursorWindow size due to error -12 错误解决方法
- Could not allocate CursorWindow error -12
- android数据库操作问题:could not allocate cursorwindow,errno:-12
- CursorWindow can not be created due to cursor [memory] leak
- CursorWindow can not be created due to cursor [memory] leak
- IllegalStateExceptio: Couldn't read row * from CursorWindow due to CursorWindow.nativeGetLong
- Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 775920 bytes) 问题解决
- Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 775920 bytes)
- Fatal error: Allowed memory size of 12582912 bytes exhausted (tried to allocate 62 bytes) in
- Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 393216 byt
- 问题解决Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 38218371 bytes)
- magento PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate xxxxx)
- 火狐内核GeckoFX浏览器开发--防止拖入文件直接打开
- git 怎么用命令发送patch补丁…
- 在windows下安装ROR的坑
- 序列化继承(转)
- 启动tomcat报错,host-manager does not exist
- CursorWindow: Could not allocate CursorWindow '......'of size 2097152 due to error -12.
- Java 常量池
- 设置eclipse的代码字体
- 基于jQuery的上传插件uploadify-已实践
- mysql 日期时间比较
- Java中线程间的通信(synchronized,wait,notify)
- navicate查询后不能直接编辑数据?
- SQL Server之存储过程基础知识(1)
- Linux下利用FIFO+Thread实现聊天