java.lang.OutOfMemoryError how to fix this
<p>i found a code but sometimes have error :</p>

<pre><code>StringBuilder strHeaders = new StringBuilder();
char c;
while ((c = (char)stream.read()) != -1) {
    strHeaders.append(c);
    if (strHeaders.length() &gt; 5 &amp;&amp; (strHeaders.substring((strHeaders.length() - 4), strHeaders.length()).equals("\r\n\r\n"))) {
        // end of headers
        break;
    }
}
</code></pre>

<p>logcat</p>

<pre><code>java.lang.OutOfMemoryError
    at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:95)
    at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:140)
    at java.lang.StringBuilder.append(StringBuilder.java:125)
    at myApp.activity.com.getFromPLS.retreiveMetadata(getFromPLS.java:98)
    at myApp.activity.com.getFromPLS.refreshMeta(getFromPLS.java:76)
    at myApp.activity.com.myApp$1.run(myApp.java:371)
    at android.os.Handler.handleCallback(Handler.java:587)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3683)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
    at dalvik.system.NativeStart.main(Native Method)
</code></pre>

<p>error on this line </p>

<pre><code>strHeaders.append(c);
</code></pre>

<p>please any one can help me to fix this ?</p>
