0

I suddenly started receiving this crash :

Non-fatal Exception: java.lang.OutOfMemoryError
    Failed to allocate a 2037654060 byte allocation with 33554336 free bytes and 170MB until OOM
     Raw
    com.android.volley.toolbox.DiskBasedCache.streamToBytes (DiskBasedCache.java:322)
    com.android.volley.toolbox.DiskBasedCache.readString (DiskBasedCache.java:532)
    com.android.volley.CacheDispatcher.run (CacheDispatcher.java:84)

my parseNetworkResponse:

 @Override
 protected Response<T> parseNetworkResponse(NetworkResponse response) {
    try {
      String json = new String( response.data, HttpHeaderParser.parseCharset(response.headers));

      return Response.success( gson.fromJson(json, class), HttpHeaderParser.parseCacheHeaders(response));

I've tried adding setShouldCache(false); to the parseNetworkResponse callback method but that doesn't solve the issue.

BVtp
  • 2,308
  • 2
  • 29
  • 68
  • Possible duplicate of [How to solve java.lang.OutOfMemoryError trouble in Android](http://stackoverflow.com/questions/25719620/how-to-solve-java-lang-outofmemoryerror-trouble-in-android) –  May 09 '16 at 09:55

2 Answers2

0

in your manifest add android:largeHeap="true" and also read these http://android-developers.blogspot.in/2009/01/avoiding-memory-leaks.html

susaine
  • 141
  • 1
  • 9
0

Are you particularly caching files are some other data in your application?? If so pl. delete the previous data on first launch and then store it, before that check if space exists.

witted_coder
  • 161
  • 1
  • 14