I am getting an OutOfMemoryException
when processing a very long JSON response
returned by the code below:
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpGETRequest = new HttpGet(url);
HttpResponse response = httpclient.execute(httpGETRequest);
return EntityUtils.toString(response.getEntity());
Even though I use System.gc()
before I call the http request, the exception still occurs.
I tried to look for the cause of the problem by saving the response on a notepad and check its size, just to find out that it is a 5mb file.
What are the things that should be done in order to avoid the exception?
Thanks for your help in advance.