memory issue in application in android
<p>Hi frineds
I am getting large or big value from webservice.I am using sax parser parsing the value and add it in arraylist.from arraylist I am adding to tablelayout with scrollview at the I am getting out of memory error in android can anybody tell what i will do to  solve the issue ?  is there anyway to do increase heap size or free heap memory? can anybody tell which parsing is best for parsing large xml file?</p>

<p>I have nearly 7000 to 10000 record like article details title </p>

<p>any help would be appreciated</p>

<p>my stack trace </p>

<pre><code>II/dalvikvm-heap(  992): Clamp target GC heap from 16.810MB to 16.000MB
D/dalvikvm(  992): GC freed 4148 objects / 272832 bytes in 386ms
I/dalvikvm-heap(  992): Forcing collection of SoftReferences for 8704-byte alloc
ation
I/dalvikvm-heap(  992): Clamp target GC heap from 16.810MB to 16.000MB
D/dalvikvm(  992): GC freed 0 objects / 0 bytes in 353ms
E/dalvikvm-heap(  992): Out of memory on a 8704-byte allocation.
I/dalvikvm(  992): "main" prio=5 tid=3 RUNNABLE
I/dalvikvm(  992):   | group="main" sCount=0 dsCount=0 s=N obj=0x4001b268 self=0
xbd00
I/dalvikvm(  992):   | sysTid=992 nice=0 sched=0/0 cgrp=default handle=-13440013
84
I/dalvikvm(  992):   at android.view.ViewGroup.addInArray(ViewGroup.java:~1918)
I/dalvikvm(  992):   at android.view.ViewGroup.addViewInner(ViewGroup.java:1879)

I/dalvikvm(  992):   at android.view.ViewGroup.addView(ViewGroup.java:1756)
I/dalvikvm(  992):   at android.widget.TableLayout.addView(TableLayout.java:418)

I/dalvikvm(  992):   at android.view.ViewGroup.addView(ViewGroup.java:1713)
I/dalvikvm(  992):   at android.widget.TableLayout.addView(TableLayout.java:400)

I/dalvikvm(  992):   at android.view.ViewGroup.addView(ViewGroup.java:1693)
I/dalvikvm(  992):   at android.widget.TableLayout.addView(TableLayout.java:391)

I/dalvikvm(  992):   at com.inquest.HomeSearchArticle$HomeSearchTask.onPostExecu
te(HomeSearchArticle.java:199)
I/dalvikvm(  992):   at com.inquest.HomeSearchArticle$HomeSearchTask.onPostExecu
te(HomeSearchArticle.java:1)
I/dalvikvm(  992):   at android.os.AsyncTask.finish(AsyncTask.java:417)
I/dalvikvm(  992):   at android.os.AsyncTask.access$300(AsyncTask.java:127)
I/dalvikvm(  992):   at android.os.AsyncTask$InternalHandler.handleMessage(Async
Task.java:429)
I/dalvikvm(  992):   at android.os.Handler.dispatchMessage(Handler.java:99)
I/dalvikvm(  992):   at android.os.Looper.loop(Looper.java:123)
I/dalvikvm(  992):   at android.app.ActivityThread.main(ActivityThread.java:4363
)
I/dalvikvm(  992):   at java.lang.reflect.Method.invokeNative(Native Method)
I/dalvikvm(  992):   at java.lang.reflect.Method.invoke(Method.java:521)
I/dalvikvm(  992):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.r
un(ZygoteInit.java:860)
I/dalvikvm(  992):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:
618)
I/dalvikvm(  992):   at dalvik.system.NativeStart.main(Native Method)
I/dalvikvm(  992):
I/System.out(  992): ######out of memory error is###java.lang.OutOfMemoryError
I/dalvikvm-heap(  992): Clamp target GC heap from 17.270MB to 16.000MB
D/dalvikvm(  992): GC freed 8418 objects / 744936 bytes in 468ms
I/dalvikvm-heap(  992): Clamp target GC heap from 17.471MB to 16.000MB
D/dalvikvm(  992): GC freed 8605 objects / 481136 bytes in 428ms
I/dalvikvm-heap(  992): Clamp target GC heap from 17.583MB to 16.000MB
D/dalvikvm(  992): GC freed 5050 objects / 297248 bytes in 413ms
I/dalvikvm-heap(  992): Clamp target GC heap from 17.595MB to 16.000MB
D/dalvikvm(  992): GC freed 1927 objects / 77160 bytes in 515ms
I/dalvikvm-heap(  992): Forcing collection of SoftReferences for 1028-byte alloc
ation
I/dalvikvm-heap(  992): Clamp target GC heap from 17.594MB to 16.000MB
D/dalvikvm(  992): GC freed 79 objects / 1264 bytes in 495ms
E/dalvikvm-heap(  992): Out of memory on a 1028-byte allocation.
I/dalvikvm(  992): "main" prio=5 tid=3 RUNNABLE
I/dalvikvm(  992):   | group="main" sCount=0 dsCount=0 s=N obj=0x4001b268 self=0
xbd00
I/dalvikvm(  992):   | sysTid=992 nice=0 sched=0/0 cgrp=default handle=-13440013
84
I/dalvikvm(  992):   at android.text.StaticLayout.generate(StaticLayout.java:~13
8)
I/dalvikvm(  992):   at android.text.StaticLayout.&lt;init&gt;(StaticLayout.java:97)
I/dalvikvm(  992):   at android.text.StaticLayout.&lt;init&gt;(StaticLayout.java:54)
I/dalvikvm(  992):   at android.text.StaticLayout.&lt;init&gt;(StaticLayout.java:45)
I/dalvikvm(  992):   at android.widget.TextView.makeNewLayout(TextView.java:4914
)
I/dalvikvm(  992):   at android.widget.TextView.onMeasure(TextView.java:5176)
I/dalvikvm(  992):   at android.view.View.measure(View.java:7964)
I/dalvikvm(  992):   at android.widget.TableRow.getColumnsWidths(TableRow.java:3
08)
I/dalvikvm(  992):   at android.widget.TableLayout.findLargestCells(TableLayout.
java:497)
I/dalvikvm(  992):   at android.widget.TableLayout.measureVertical(TableLayout.j
ava:462)
I/dalvikvm(  992):   at android.widget.TableLayout.onMeasure(TableLayout.java:42
8)
I/dalvikvm(  992):   at android.view.View.measure(View.java:7964)
I/dalvikvm(  992):   at android.widget.ScrollView.measureChildWithMargins(Scroll
View.java:893)
I/dalvikvm(  992):   at android.widget.FrameLayout.onMeasure(FrameLayout.java:24
5)
I/dalvikvm(  992):   at android.widget.ScrollView.onMeasure(ScrollView.java:276)

I/dalvikvm(  992):   at android.view.View.measure(View.java:7964)
I/dalvikvm(  992):   at android.widget.RelativeLayout.measureChildHorizontal(Rel
ativeLayout.java:569)
I/dalvikvm(  992):   at android.widget.RelativeLayout.onMeasure(RelativeLayout.j
ava:361)
I/dalvikvm(  992):   at android.view.View.measure(View.java:7964)
I/dalvikvm(  992):   at android.view.ViewGroup.measureChildWithMargins(ViewGroup
.java:3023)
I/dalvikvm(  992):   at android.widget.FrameLayout.onMeasure(FrameLayout.java:24
5)
I/dalvikvm(  992):   at android.view.View.measure(View.java:7964)
I/dalvikvm(  992):   at android.view.ViewGroup.measureChildWithMargins(ViewGroup
.java:3023)
I/dalvikvm(  992):   at android.widget.FrameLayout.onMeasure(FrameLayout.java:24
5)
I/dalvikvm(  992):   at android.view.View.measure(View.java:7964)
I/dalvikvm(  992):   at android.view.ViewGroup.measureChildWithMargins(ViewGroup
.java:3023)
I/dalvikvm(  992):   at android.widget.FrameLayout.onMeasure(FrameLayout.java:24
5)
I/dalvikvm(  992):   at android.view.View.measure(View.java:7964)
I/dalvikvm(  992):   at android.view.ViewGroup.measureChildWithMargins(ViewGroup
.java:3023)
I/dalvikvm(  992):   at android.widget.FrameLayout.onMeasure(FrameLayout.java:24
5)
I/dalvikvm(  992):   at android.view.View.measure(View.java:7964)
I/dalvikvm(  992):   at android.view.ViewGroup.measureChildWithMargins(ViewGroup
.java:3023)
I/dalvikvm(  992):   at android.widget.FrameLayout.onMeasure(FrameLayout.java:24
5)
I/dalvikvm(  992):   at android.view.View.measure(View.java:7964)
I/dalvikvm(  992):   at android.widget.RelativeLayout.measureChildHorizontal(Rel
ativeLayout.java:569)
I/dalvikvm(  992):   at android.widget.RelativeLayout.onMeasure(RelativeLayout.j
ava:361)
I/dalvikvm(  992):   at android.view.View.measure(View.java:7964)
I/dalvikvm(  992):   at android.view.ViewGroup.measureChildWithMargins(ViewGroup
.java:3023)
I/dalvikvm(  992):   at android.widget.FrameLayout.onMeasure(FrameLayout.java:24
5)
I/dalvikvm(  992):   at android.view.View.measure(View.java:7964)
I/dalvikvm(  992):   at android.view.ViewGroup.measureChildWithMargins(ViewGroup
.java:3023)
I/dalvikvm(  992):   at android.widget.LinearLayout.measureChildBeforeLayout(Lin
earLayout.java:888)
I/dalvikvm(  992):   at android.widget.LinearLayout.measureHorizontal(LinearLayo
ut.java:619)
I/dalvikvm(  992):   at android.widget.LinearLayout.onMeasure(LinearLayout.java:
280)
I/dalvikvm(  992):   at android.view.View.measure(View.java:7964)
I/dalvikvm(  992):   at android.view.ViewGroup.measureChildWithMargins(ViewGroup
.java:3023)
I/dalvikvm(  992):   at android.widget.FrameLayout.onMeasure(FrameLayout.java:24
5)
I/dalvikvm(  992):   at android.view.View.measure(View.java:7964)
I/dalvikvm(  992):   at android.view.ViewGroup.measureChildWithMargins(ViewGroup
.java:3023)
I/dalvikvm(  992):   at android.widget.FrameLayout.onMeasure(FrameLayout.java:24
5)
I/dalvikvm(  992):   at android.view.View.measure(View.java:7964)
I/dalvikvm(  992):   at android.view.ViewRoot.performTraversals(ViewRoot.java:76
3)
I/dalvikvm(  992):   at android.view.ViewRoot.handleMessage(ViewRoot.java:1633)
I/dalvikvm(  992):   at android.os.Handler.dispatchMessage(Handler.java:99)
I/dalvikvm(  992):   at android.os.Looper.loop(Looper.java:123)
I/dalvikvm(  992):   at android.app.ActivityThread.main(ActivityThread.java:4363
)
I/dalvikvm(  992):   at java.lang.reflect.Method.invokeNative(Native Method)
I/dalvikvm(  992):   at java.lang.reflect.Method.invoke(Method.java:521)
I/dalvikvm(  992):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.r
un(ZygoteInit.java:860)
I/dalvikvm(  992):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:
618)
I/dalvikvm(  992):   at dalvik.system.NativeStart.main(Native Method)
I/dalvikvm(  992):
D/AndroidRuntime(  992): Shutting down VM
W/dalvikvm(  992): threadid=3: thread exiting with uncaught exception (group=0x4
001b188)
E/AndroidRuntime(  992): Uncaught handler: thread main exiting due to uncaught e
xception
I/dalvikvm-heap(  992): Clamp target GC heap from 17.609MB to 16.000MB
D/dalvikvm(  992): GC freed 289 objects / 10728 bytes in 407ms
I/dalvikvm-heap(  992): Forcing collection of SoftReferences for 938-byte alloca
tion
I/dalvikvm-heap(  992): Clamp target GC heap from 17.609MB to 16.000MB
D/dalvikvm(  992): GC freed 0 objects / 0 bytes in 402ms
E/dalvikvm-heap(  992): Out of memory on a 938-byte allocation.
I/dalvikvm(  992): "main" prio=5 tid=3 RUNNABLE
I/dalvikvm(  992):   | group="main" sCount=0 dsCount=0 s=N obj=0x4001b268 self=0
xbd00
I/dalvikvm(  992):   | sysTid=992 nice=0 sched=0/0 cgrp=default handle=-13440013
84
I/dalvikvm(  992):   at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractSt
ringBuilder.java:~97)
I/dalvikvm(  992):   at java.lang.AbstractStringBuilder.append0(AbstractStringBu
ilder.java:131)
I/dalvikvm(  992):   at java.lang.StringBuffer.append(StringBuffer.java:273)
I/dalvikvm(  992):   at java.io.StringWriter.write(StringWriter.java:138)
I/dalvikvm(  992):   at java.io.PrintWriter.doWrite(PrintWriter.java:711)
I/dalvikvm(  992):   at java.io.PrintWriter.write(PrintWriter.java:686)
I/dalvikvm(  992):   at java.io.PrintWriter.write(PrintWriter.java:661)
I/dalvikvm(  992):   at java.io.PrintWriter.write(PrintWriter.java:729)
I/dalvikvm(  992):   at java.io.PrintWriter.print(PrintWriter.java:492)
I/dalvikvm(  992):   at java.io.PrintWriter.println(PrintWriter.java:623)
I/dalvikvm(  992):   at java.lang.Throwable.printStackTrace(Throwable.java:316)
I/dalvikvm(  992):   at android.util.Log.getStackTraceString(Log.java:234)
I/dalvikvm(  992):   at com.android.internal.os.RuntimeInit.crash(RuntimeInit.ja
va:315)
I/dalvikvm(  992):   at com.android.internal.os.RuntimeInit$UncaughtHandler.unca
ughtException(RuntimeInit.java:76)
I/dalvikvm(  992):   at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java
:887)
I/dalvikvm(  992):   at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java
:884)
I/dalvikvm(  992):   at dalvik.system.NativeStart.main(Native Method)
I/dalvikvm(  992):
I/dalvikvm-heap(  992): Clamp target GC heap from 17.614MB to 16.000MB
D/dalvikvm(  992): GC freed 64 objects / 5424 bytes in 447ms
I/dalvikvm-heap(  992): Forcing collection of SoftReferences for 754-byte alloca
tion
I/dalvikvm-heap(  992): Clamp target GC heap from 17.614MB to 16.000MB
D/dalvikvm(  992): GC freed 0 objects / 0 bytes in 440ms
E/dalvikvm-heap(  992): Out of memory on a 754-byte allocation.
I/dalvikvm(  992): "main" prio=5 tid=3 RUNNABLE
I/dalvikvm(  992):   | group="main" sCount=0 dsCount=0 s=N obj=0x4001b268 self=0
xbd00
I/dalvikvm(  992):   | sysTid=992 nice=0 sched=0/0 cgrp=default handle=-13440013
84
I/dalvikvm(  992):   at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractSt
ringBuilder.java:~97)
I/dalvikvm(  992):   at java.lang.AbstractStringBuilder.append0(AbstractStringBu
ilder.java:131)
I/dalvikvm(  992):   at java.lang.StringBuffer.append(StringBuffer.java:273)
I/dalvikvm(  992):   at java.io.StringWriter.write(StringWriter.java:138)
I/dalvikvm(  992):   at java.io.PrintWriter.doWrite(PrintWriter.java:711)
I/dalvikvm(  992):   at java.io.PrintWriter.write(PrintWriter.java:686)
I/dalvikvm(  992):   at java.io.PrintWriter.write(PrintWriter.java:661)
I/dalvikvm(  992):   at java.io.PrintWriter.write(PrintWriter.java:729)
I/dalvikvm(  992):   at java.io.PrintWriter.print(PrintWriter.java:492)
I/dalvikvm(  992):   at java.io.PrintWriter.println(PrintWriter.java:623)
I/dalvikvm(  992):   at java.lang.Throwable.printStackTrace(Throwable.java:316)
I/dalvikvm(  992):   at android.util.Log.getStackTraceString(Log.java:234)
I/dalvikvm(  992):   at com.android.internal.os.RuntimeInit.crash(RuntimeInit.ja
va:323)
I/dalvikvm(  992):   at com.android.internal.os.RuntimeInit$UncaughtHandler.unca
ughtException(RuntimeInit.java:76)
I/dalvikvm(  992):   at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java
:887)
I/dalvikvm(  992):   at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java
:884)
I/dalvikvm(  992):   at dalvik.system.NativeStart.main(Native Method)
I/dalvikvm(  992):
I/Process (   60): Sending signal. PID: 992 SIG: 3
I/dalvikvm(  992): threadid=7: reacting to signal 3
I/dalvikvm(  992): Wrote stack trace to '/data/anr/traces.txt'
D/dalvikvm(   60): GC freed 13970 objects / 689880 bytes in 201ms
</code></pre>

<p>Thanks</p>
