2

I'm trying to solve TransactionTooLargeExeption described in What to do on TransactionTooLargeException

We are not using onSaveInstanceState in any siginificant way.

We are passing extra data when starting intent which is about 10-20k of data.

And app crashes after opening the activity about 30 times.

I'm speculating the extra data stacks up and crashes app, and thinking of doing getIntent().removeExtra("data") after I get the extra data in the receiving activity.

Is this usual to having to remove the received intent?

eugene
  • 39,839
  • 68
  • 255
  • 489
  • I would assume it means that you are somehow holding on to the intent or the data, which is not allowing it to be garbage collected. – lionscribe Oct 14 '18 at 05:23

1 Answers1

0

Here is the Source code of getExtras() Method

public Bundle getExtras() {

   return (mExtras != null)
        ? new Bundle(mExtras)
        : null;
}

As you can see, Every time you call getExtras() it creates a Copy of your Data (in your case your data is too large )

So, i suggest you to remove your Extra after receiving it so you can free up your memory and avoid such an exception by using removeExtra() as you mentioned earlier.

Mohamed Yehia
  • 400
  • 1
  • 5
  • 15
  • This is nothing. It only makes a shallow copy, so very little extra memory used. Also, the copy will be released as soon as the piece of code finishes, and will not stay in memory. – lionscribe Oct 15 '18 at 04:46