caused By:java.lang.OutOfMemoryError:Failed to allocate a 38428990 byte allocation with 23734224

Source: Internet
Author: User

About memory overflow problem, here is a network request, return JSON data

HttpURLConnection connection = (httpurlconnection) httpurl
        . OpenConnection ();
Set  the parameter request to get request
connection.setreadtimeout (5000);
Connection.setrequestmethod ("get");

Connection.getinputstream () Gets the byte input stream, InputStreamReader the bridge from byte to character, plus the wrapper character streams
BufferedReader BufferedReader = new BufferedReader (
        New InputStreamReader (Connection.getinputstream ()));
Create a string container
stringbuffer sb = new StringBuffer ();
String str = "";
Row Read
while ((str = bufferedreader.readline ())!= null) {
    //When read completes, add to Container
    sb.append (str);
}
Test whether to get JSON string
log.e ("TAG", "" + sb.tostring ());
This JSON string is too large to cause buffer, failed to request memory,


Troubleshoot an Android memory overflow

Actually you can add in your list

<code style= "margin:0px; padding:0px; border:0px;  Font-family:consolas, Menlo, Monaco, ' Lucida Console ', ' Liberation Mono ', ' Dejavu Sans ', ' Mono Vera bitstream Sans ', ' Courier New ', monospace, Sans-serif; White-space:inherit; " ><span class= "ATN" style= "margin:0px; padding:0px; border:0px; COLOR:RGB (230, 67, 32); ></span></code><pre class= "Default Prettyprint prettyprinted" name= "code" style= "White-space: Pre-wrap; Word-wrap:normal; position:relative; Overflow:auto; margin-top:0px; Margin-bottom:1em; padding:5px; border:0px; Width:auto; max-height:600px;  Font-family:consolas, Menlo, Monaco, ' Lucida Console ', ' Liberation Mono ', ' Dejavu Sans ', ' Mono Vera bitstream Sans ', ' Courier New ', monospace, Sans-serif; Background-color:rgb (239, 240, 241); ><code style= "margin:0px; padding:0px; border:0px;  Font-family:consolas, Menlo, Monaco, ' Lucida Console ', ' Liberation Mono ', ' Dejavu Sans ', ' Mono Vera bitstream Sans ', ' CourierNew ', monospace, Sans-serif; White-space:inherit; " ><span class= "PLN" style= "margin:0px; padding:0px; border:0px; Color:rgb (48, 51, 54); > </span><span class= "atn" style= "margin:0px; padding:0px; border:0px; COLOR:RGB (230, 67, 32); >android:hardwareaccelerated</span><span class= "pun" style= "margin:0px; padding:0px; border:0px; Color:rgb (48, 51, 54); >=</span><span class= "ATV" style= "margin:0px; padding:0px; border:0px; Color:rgb (15, 116, 189); > "false" </span></code><span style= "font-family:arial, Helvetica, Sans-serif; Background-color:rgb (255, 255, 255); >,</span><pre class= "Default Prettyprint prettyprinted" name= "code" style= "WHITE-SPACE:PRE-WRAP; Word-wrap:normal; position:relative; Overflow:auto; margin-top:0px; Margin-bottom:1em; padding:5px; border:0px; Width:auto; max-height:600px; Font-family:consolas, Menlo, Monaco, ' Lucida Console ', ' Liberation Mono ', ' Dejavu Sans ', ' BitStream Vera Sans Mono ', ' Courier New ', monospace, Sans-serif; Background-color:rgb (239, 240, 241); ><code style= "margin:0px; padding:0px; border:0px;  Font-family:consolas, Menlo, Monaco, ' Lucida Console ', ' Liberation Mono ', ' Dejavu Sans ', ' Mono Vera bitstream Sans ', ' Courier New ', monospace, Sans-serif; White-space:inherit; " ><span class= "PLN" style= "margin:0px; padding:0px; border:0px; Color:rgb (48, 51, 54); > </span><span class= "atn" style= "margin:0px; padding:0px; border:0px; COLOR:RGB (230, 67, 32); >android:largeheap</span><span class= "pun" style= "margin:0px; padding:0px; border:0px; Color:rgb (48, 51, 54); >=</span><span class= "ATV" style= "margin:0px; padding:0px; border:0px; Color:rgb (15, 116, 189); > "true" </span></code>
Is the work of some situation,

<code style= "margin:0px; padding:0px; border:0px;  Font-family:consolas, Menlo, Monaco, ' Lucida Console ', ' Liberation Mono ', ' Dejavu Sans ', ' Mono Vera bitstream Sans ', ' Courier New ', monospace, Sans-serif; White-space:inherit; " ><span class= "tag" style= "margin:0px; padding:0px; border:0px; Color:rgb (125, 39, 39); ><application</span><span class= "PLN" style= "margin:0px; padding:0px; border:0px; Color:rgb (48, 51, 54); > </span><span class= "atn" style= "margin:0px; padding:0px; border:0px; COLOR:RGB (230, 67, 32); >android:allowbackup</span><span class= "pun" style= "margin:0px; padding:0px; border:0px; Color:rgb (48, 51, 54); >=</span><span class= "ATV" style= "margin:0px; padding:0px; border:0px; Color:rgb (15, 116, 189); > "true" </span><span class= "PLN" style= "margin:0px; padding:0px; border:0px; Color:rgb (48, 51, 54); > </span><span class= "atn" style= "margin:0px; Padding: 0px; border:0px; COLOR:RGB (230, 67, 32); >android:hardwareaccelerated</span><span class= "pun" style= "margin:0px; padding:0px; border:0px; Color:rgb (48, 51, 54); >=</span><span class= "ATV" style= "margin:0px; padding:0px; border:0px; Color:rgb (15, 116, 189); > "false" </span><span class= "PLN" style= "margin:0px; padding:0px; border:0px; Color:rgb (48, 51, 54); > </span><span class= "atn" style= "margin:0px; padding:0px; border:0px; COLOR:RGB (230, 67, 32); >android:icon</span><span class= "pun" style= "margin:0px; padding:0px; border:0px; Color:rgb (48, 51, 54); >=</span><span class= "ATV" style= "margin:0px; padding:0px; border:0px; Color:rgb (15, 116, 189); > "@mipmap/ic_launcher" </span><span class= "PLN" style= "margin:0px; padding:0px; border:0px; Color:rgb (48, 51, 54); > </span><span class= "atn" style= "margin:0px; padding:0px; border:0px; COLOR:RGB (230, 67, 32);" >android:label</span><span class= "pun" style= "margin:0px; padding:0px; border:0px; Color:rgb (48, 51, 54); >=</span><span class= "ATV" style= "margin:0px; padding:0px; border:0px; Color:rgb (15, 116, 189); > "@string/app_name" </span><span class= "PLN" style= "margin:0px; padding:0px; border:0px; Color:rgb (48, 51, 54); > </span><span class= "atn" style= "margin:0px; padding:0px; border:0px; COLOR:RGB (230, 67, 32); >android:largeheap</span><span class= "pun" style= "margin:0px; padding:0px; border:0px; Color:rgb (48, 51, 54); >=</span><span class= "ATV" style= "margin:0px; padding:0px; border:0px; Color:rgb (15, 116, 189); > "true" </span><span class= "PLN" style= "margin:0px; padding:0px; border:0px; Color:rgb (48, 51, 54); > </span><span class= "atn" style= "margin:0px; padding:0px; border:0px; COLOR:RGB (230, 67, 32); >android:supportsrtl</span><span class= "PuN "style=" margin:0px; padding:0px; border:0px; Color:rgb (48, 51, 54); >=</span><span class= "ATV" style= "margin:0px; padding:0px; border:0px; Color:rgb (15, 116, 189); > "true" </span><span class= "PLN" style= "margin:0px; padding:0px; border:0px; Color:rgb (48, 51, 54); > </span><span class= "atn" style= "margin:0px; padding:0px; border:0px; COLOR:RGB (230, 67, 32); >android:theme</span><span class= "pun" style= "margin:0px; padding:0px; border:0px; Color:rgb (48, 51, 54); >=</span><span class= "ATV" style= "margin:0px; padding:0px; border:0px; Color:rgb (15, 116, 189); > "@style/apptheme" </span><span class= "tag" style= "margin:0px; padding:0px; border:0px; Color:rgb (125, 39, 39); >></span></code>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.