排球的OutOfMemoryError引起全MessageQueue [英] Volley OutOfMemoryError caused by full MessageQueue

查看:299
本文介绍了排球的OutOfMemoryError引起全MessageQueue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是用排枪库的元数据下载一些项目,这是在XML格式返回。 一切都将按预期的项目合理数量的,但是当他们太多 - 7000 - 应用程序耗尽可用内存和我得到这个错误(补时ACRA库):

I am using Volley library to download metadata for some items, which is returned in XML format. Everything works as expected for a reasonable amount of items, but when they are too many - about 7000 - the app runs out of available memory and I get this error (caught with ACRA library):

03-21 11:08:31.362: E/ACRA(16922): java.lang.OutOfMemoryError
03-21 11:08:31.362: E/ACRA(16922):  at java.lang.String.<init>(String.java:255)
03-21 11:08:31.362: E/ACRA(16922):  at java.lang.String.<init>(String.java:228)
03-21 11:08:31.362: E/ACRA(16922):  at com.android.volley.toolbox.StringRequest.parseNetworkResponse(StringRequest.java:67)
03-21 11:08:31.362: E/ACRA(16922):  at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:121)

我也得到编舞邮件抱怨丢帧。 我使用的凌空抽射,使通用 StringRequest 和所有的请求都通过一个唯一的处理请求队列

I also get Choreographer messages complaining about dropped frames. I am using volley to make common StringRequests and all of the Requests are handled by a unique RequestQueue.

使用Eclipse MAT我发现大部分的堆是由占用 MessageQueue 仍然有旧的XML中存储。当然,这使得应用程序崩溃,如果我有执行请求的很多(千)。

Using Eclipse MAT I found out that most of the heap is occupied by a MessageQueue that still has the old XML stored inside. This of course makes the app crash if I've to perform a lot (thousands) of requests.

我怎样才能清空MessageQueue?

How can I empty the MessageQueue?

推荐答案

随着榕柯克帕特里克自己的表示,凌空库在内存中保存所有的答复,所以它不是为多,大的反应的最佳解决方案。

As Ficus Kirkpatrick himself stated, the volley library holds all the responses in memory, so it's not the best solution for multiple and large responses.

余即将切换到另一个网络库,因为它似乎是唯一可能的解决方案。

I will soon switch to another network library as it seems to be the only possible solution.

编辑:我终于找到了一个解决方案通过改造+ okhttp!

I finally found a solution using retrofit+okhttp!

这篇关于排球的OutOfMemoryError引起全MessageQueue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆