java - OutOfMemory on string which is response XML -


conditions:

i have url, returns me xml, ~3mb of data. string, parse xml, , save it. complete process happens in async task.

two problems:

  1. my ui thread blocked until server data parsed.
  2. i outofmemory error on string in cases

// calling code

{ httpentity entity = response.getentity(); inputstream in = entity.getcontent(); value = convertstreamtostring(in).tostring(); return value; }   // helper function     public static string convertstreamtostring(java.io.inputstream is) {         try {             return new java.util.scanner(is).usedelimiter("\\a").next();         } catch (exception e) {             return "";         } catch (outofmemoryerror ex) {             commonlib.zlog("splash", "out of memory exception while download");             return "";         }     } 

try this, if minimum version of sdk 11 or greater,

add following application tag in manifest

android:largeheap="true" 

some of people says not best way,but in application working suggesting you.

hope you.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -