Android - App crashing due to memory error -
i have app not graphic intensive (as such). has 2 fragments, both 2 gridviews inside. call level-1 activities because visible when app opened.
now second gridview located inside fragment #2 has 3 items, 1 of these items opens new activity gridview inside it. call level-2 activities must accessed user.
this second level gridview has 8 image items. items identical size , shape, images used them not, scaled/resized etc. images are:
image 1 - 465x232, 38kb
image 2 - 512x251, 41kb
image 3 - 900x379, 68kb
image 4 - 630x258, 35kb
image 5 - 700x346, 44kb
image 6 - 615x409, 24kb
image 7 - 800x383, 64kb
image 8 - 400x169, 26kb
gridview xml
<gridview android:id="@+id/essentials_gridview" android:layout_width="fill_parent" android:layout_height="match_parent" android:gravity="center" android:horizontalspacing="10dp" android:verticalspacing="10dp" android:listselector="@android:color/transparent" android:numcolumns="3" android:padding="10dp" android:stretchmode="columnwidth" />
gridview item layout
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="125dp" > <imageview android:id="@+list/grid_item_image_image" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scaletype="centercrop" />" <textview android:id="@+list/grid_item_image_text" android:layout_width="fill_parent" android:layout_height="30dp" android:layout_alignparentbottom="true" android:gravity="center" android:textsize="20sp" android:textcolor="#ffffff" android:background="#50000000" android:singleline="true" android:ellipsize="end" /> </relativelayout>
the error is:
08-10 10:09:42.060: e/dalvikvm-heap(18982): out of memory on 9023376-byte allocation.
this happens when i'm moving , forth between level 1 , level 2 activities. after couple of times, crashes error.
seems have memory leak, suggest watch session:
google i/o 2011: memory management android apps
in own experience, recommend implement viewholder pattern inside gridview's adapters.
Comments
Post a Comment