0

I am trying to make my deep nested list of objects parcelable but the application keeps crashing due to the "Out of memory exception" when simulating process restart due to low memory. My classes:

class Base implements Parcelable{

    protected Double mDouble1;
    protected Double mDouble2;
    protected Double mDouble3;
    protected Double mDouble4;
}

class A extends Base{
    List<B> mBList = new ArrayList<>();
}

class B extends Base{
    List<C> mCList = new ArrayList<>();
}

class C extends Base{
    List<D> mDList = new ArrayList<>();
}

class D extends Base{

}

class RESTRequest implements Parcelable{
    int int1;
    String s;
    List<A> mAList = new ArrayList<>();
}
arjang27
  • 241
  • 6
  • 13
  • Parcelable generally take up a lot of memory. Since you have nested list of objects the memory requirement is bound to go up. I would suggest using GSON to convert your object into a string and pass it. You can use GSON again to get back your object. – Ragesh Ramesh Feb 27 '16 at 02:36
  • I'm using Retrofit and GSON. The app works as expected, it crashes only when simulating process restart. – arjang27 Feb 27 '16 at 10:46

0 Answers0