Note that there are some explanatory texts on larger screens.

plurals
  1. POMemory dumps when reading from server causes Android app to load too slowly
    primarykey
    data
    text
    <p>I'm making an Android app for my WordPress blog and I've set up a static class Server.java in my Android app to communicate with a PHP file that I created on my hosting servers.</p> <p>I use URLConnection, DataOutputStream and DataInputStream to do the communication. One of my functions gets the latest 10 posts from my WordPress, and is retrieved the following way...</p> <p>In any of my java files, call <code>Server.getPosts();</code> Below is my Server.java file (the parts you need to see, at least)</p> <pre><code>public class Server { public static final String SERVER_URL = "http://www.startingtofeelit.com/android-server.php"; public static String getPosts() { return executeHttpRequest("command=getPosts"); } @SuppressWarnings("deprecation") private static String executeHttpRequest(String data) { String result = new String(); try { URL url = new URL(SERVER_URL); URLConnection connection = url.openConnection(); connection.setDoInput(true); connection.setDoOutput(true); connection.setUseCaches(false); connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); DataOutputStream dataOut = new DataOutputStream(connection.getOutputStream()); dataOut.writeBytes(data); dataOut.flush(); dataOut.close(); // get the response from the server and store it in result DataInputStream dataIn = new DataInputStream(connection.getInputStream()); String inputLine; while ((inputLine = dataIn.readLine()) != null) { result += inputLine; } dataIn.close(); } catch (IOException e) { result = null; } System.out.println("Returning from Server.java"); return result; } } </code></pre> <p>I got most of this code from a guide online. It returns a string that has the xml representation of my posts. If you'd like, you can view the xml/return string <a href="http://www.startingtofeelit.com/android-server.php?action=getPosts" rel="nofollow">here</a>, but that is not really necessary for you to help me.</p> <p>My main problem is here: I'm getting a huge amount of memory dumps. Something in the way my code is set up, I get massive amounts of memory dumps with the tag "dalvikvm" and the message <code>GC_CONCURRENT freed 312K, 5% free 9989K/10439K, paused 10ms+15ms</code> in my Eclipse LogCat, and other messages similar to that. It slows down the load of my app immensely. It seems to originating in my while loop, but I don't know how else to do this. Any help?</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.
    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