Domanda

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)

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.

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.

How can I empty the MessageQueue?

È stato utile?

Soluzione

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.

EDIT: I finally found a solution using retrofit+okhttp!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top