Tuesday, April 3, 2012

[android-developers] Large data downloads from a Web app to Android client getting Out of memory error

I'm sending the following request to a Web app running on Tomcat:

connection = (HttpsURLConnection) url.openConnection();

writer = new BufferedWriter(new
OutputStreamWriter(connection.getOutputStream()));
writer.write("email_addr=" + URLEncoder.encode(email_addr, "UTF-8") +
"&" + "passwd=" +
URLEncoder.encode(password, "UTF-8") + "&" +
"cmd=" + tmp + "&" + "parms=" + URLEncoder.encode(parms,
"UTF-8"));
writer.close();

and then read the response as follows:

rdr = new BufferedReader(new
InputStreamReader(connection.getInputStream()));
tmp = rdr.readLine();

Everything works fine as long as the data coming back is less than
around 5 MB. Then I get an error on readLine():

04-02 16:51:34.232: E/dalvikvm-heap(3907): Out of memory on a 10309582-
byte allocation

Anyone have any ideas on why this is happening and how to fix it?

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate