Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid HttpClient Outof memory Error (xml data)
    primarykey
    data
    text
    <p>I am having a problem to read large data from xml web service the xml file is about 5.5Mb and the code crashes and raise out of memory error </p> <p>Here is my function</p> <pre><code> private static HttpResponse executePostHttpRequest(String baseUrl, String names[], String values[]) throws ClientProtocolException, IOException { final HttpClient client = newHttpClientInstance(); HttpPost request = new HttpPost(baseUrl); boolean haveData = (names != null) &amp;&amp; (values != null); // if we have data, form it into request if (haveData) { List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(values.length); for (int i = 0; i &lt; values.length; i++) { nameValuePairs.add(new BasicNameValuePair(names[i], values[i])); } try { request.setEntity(new UrlEncodedFormEntity(nameValuePairs, "utf-8")); } catch (UnsupportedEncodingException e) { request.setEntity(new UrlEncodedFormEntity(nameValuePairs)); } } request.addHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8"); // return response created by executing this request return client.execute(request); </code></pre> <p>}</p> <p>and here is my dumb</p> <pre><code> 12-05 23:30:31.813: I/dalvikvm-heap(443): Forcing collection of SoftReferences for 4842758-byte allocation 12-05 23:30:31.964: D/dalvikvm(443): GC freed 0 objects / 0 bytes in 143ms 12-05 23:30:31.964: E/dalvikvm-heap(443): Out of memory on a 4842758-byte allocation. 12-05 23:30:31.964: I/dalvikvm(443): "pool-1-thread-3" prio=5 tid=35 RUNNABLE 12-05 23:30:31.977: I/dalvikvm(443): | group="main" sCount=0 dsCount=0 s=N obj=0x44f92608 self=0x3d92a0 12-05 23:30:31.977: I/dalvikvm(443): | sysTid=460 nice=0 sched=0/0 cgrp=default handle=3901200 12-05 23:30:31.984: I/dalvikvm(443): at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:~97) 12-05 23:30:31.984: I/dalvikvm(443): at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:155) 12-05 23:30:31.984: I/dalvikvm(443): at java.lang.StringBuilder.append(StringBuilder.java:216) 12-05 23:30:31.984: I/dalvikvm(443): at com.XXXXXXXXX.api.HttpUtils.convertStreamToString(HttpUtils.java:308) 12-05 23:30:31.993: I/dalvikvm(443): at com.XXXXXXXXX.api.HttpUtils.responseToString(HttpUtils.java:331) 12-05 23:30:31.993: I/dalvikvm(443): at com.XXXXXXXXX.api.HttpUtils.executeRequest(HttpUtils.java:208) 12-05 23:30:31.993: I/dalvikvm(443): at com.XXXXXXXXX.api.HttpUtils.access$0(HttpUtils.java:188) 12-05 23:30:31.993: I/dalvikvm(443): at com.XXXXXXXXX.api.HttpUtils$3.run(HttpUtils.java:171) 12-05 23:30:31.993: I/dalvikvm(443): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068) 12-05 23:30:31.993: I/dalvikvm(443): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561) 12-05 23:30:31.993: I/dalvikvm(443): at java.lang.Thread.run(Thread.java:1096) 12-05 23:30:33.024: D/HttpUtils(443): Throwable: java.lang.OutOfMemoryError 12-05 23:30:35.383: D/HttpUtils(443): Throwable: java.lang.OutOfMemoryError </code></pre> <p>Any advice?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload