Out Of Memory String Android

android, out-of-memory

Solution

The best solution I found was to raise the Heap of the Application.

I placed `android:largeHeap="true"` under the `<application/>` in the `AndroidManifest.xml`.

Problem

I am receiving huge JSON and and while I am reading the lines OutOfMemoryError appears. Here is my first method that I am trying to parse the JSON. ``` InputStream in = response.getEntity().getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF-8"), 8); String result = ""; while (true) { String ss = reader.readLine(); if (ss == null) { break; } result += ss; } ``` And I've also tried this method. ``` InputStream in = response.getEntity().getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF-8"), 8); StringBuilder sb = new StringBuilder(); String line = null; while ( (line = reader.readLine()) != null) { sb.append(line); } ``` In the both of the cases the OutOfMemoryErorr is appearing.

Original source

Related problems