How to prevent OutofMemoryError when building up a long list of string in android
<p>we get the following error in our app:</p>

<pre><code>java.lang.OutOfMemoryError
at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:95)
at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:153)
at java.lang.StringBuilder.append(StringBuilder.java:217)
</code></pre>

<p>And we believe this is due to:
<a href="http://stackoverflow.com/questions/5761547/out-of-memory-errors-occur-with-a-high-heap-size-but-low-allocated-size-why">Out of memory errors occur with a high heap size but low allocated size. Why?</a></p>

<p>Is there a way to defragment the memory?</p>

<p>How do we prevent this from happening? Our idea was to slice the big StringBuilder into multiple instance and create new instances for when we have reached a maximum length we have specified? Is this going to work?</p>
