Android: unique memory exception. How to check objects?

Here's the setting:

  • I have an activity with a list of elements (updated from the server, represented by a simple Java class). Elements are displayed through a custom BaseAdapter and a custom view for each row.
  • Elements are implemented by Parcelable, so when the screen is rotated, the elements are saved as a ParcelableArrayList and then restored without returning to the server.

This is still a fairly simple setup, but I want to transfer one of these elements to another activity. The bundle has a pubExtra (String, Parcelable) method that I wanted to use to place the object there and then pass it using intent. When I did this, the device began to receive power due to an OutOfMemoryException. It seems, trying to parallelize the object, it asks for ~ 30mb (!)

It seems that the object should contain references to something else, since the object itself contains only a few int / float / String fields and the methods associated with them. I was not able to track this by looking at the code inspector or debugging, and I don't know how to use the heap viewer effectively.

Any suggestions?

Here stacktrace

/dalvikvm-heap( 5876): Out of memory on a 29098436-byte allocation.
I/dalvikvm( 5876): "main" prio=5 tid=1 RUNNABLE
I/dalvikvm( 5876):   | group="main" sCount=0 dsCount=0 s=N obj=0x4001d8d0 self=0xccc8
I/dalvikvm( 5876):   | sysTid=5876 nice=0 sched=0/0 cgrp=default handle=-1345017816
I/dalvikvm( 5876):   | schedstat=( 1107116708 1124999998 2626 )
I/dalvikvm( 5876):   at java.util.ArrayList.<init>(ArrayList.java:~84)
I/dalvikvm( 5876):   at android.os.Parcel.readArrayList(Parcel.java:1460)
I/dalvikvm( 5876):   at android.os.Parcel.readValue(Parcel.java:1792)
I/dalvikvm( 5876):   at android.os.Parcel.readMapInternal(Parcel.java:2007)
I/dalvikvm( 5876):   at android.os.Bundle.unparcel(Bundle.java:208)
I/dalvikvm( 5876):   at android.os.Bundle.containsKey(Bundle.java:249)
I/dalvikvm( 5876):   at <mypackage>.BaseDetailsActivity.isInModifyState(BaseDetailsActivity.java:184)
I/dalvikvm( 5876):   at <mypackage>.DetailsActivity.onCreate(DetailsActivity.java:230)
I/dalvikvm( 5876):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
I/dalvikvm( 5876):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
I/dalvikvm( 5876):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
I/dalvikvm( 5876):   at android.app.ActivityThread.access$2300(ActivityThread.java:125)
I/dalvikvm( 5876):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
I/dalvikvm( 5876):   at android.os.Handler.dispatchMessage(Handler.java:99)
I/dalvikvm( 5876):   at android.os.Looper.loop(Looper.java:123)
I/dalvikvm( 5876):   at android.app.ActivityThread.main(ActivityThread.java:4627)
I/dalvikvm( 5876):   at java.lang.reflect.Method.invokeNative(Native Method)
I/dalvikvm( 5876):   at java.lang.reflect.Method.invoke(Method.java:521)
I/dalvikvm( 5876):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
I/dalvikvm( 5876):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
I/dalvikvm( 5876):   at dalvik.system.NativeStart.main(Native Method)
+5
source share
2

, : , . , Parcelable .

, , "Stop reading!". . , , , , . * , , , / .

: , /

  • . Google, , - .

: , . ArrayLists Parcel

+14

Eclipse Memory Analyzer Tool. Eclipse, "Dump Hprof file" DDMS ( "" ). MAT Eclipse .

, - .

+5

All Articles