I am using Android Studio 3.0.1 which allows to inspect the Bundle
object in onSaveInstanceState
:
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
}
To do so add a breakpoint and once the debugger stops right click the Bundle
object as shown in the screenshot and select "Show Bundle Objects..." from the context menu.
Then a window opens to list the Bundle
objects as shown in this screenshot:
Is there a way to find out how much memory the whole Bundle
and it's children occupy? I want to identify the bigger chunks to optimize and avoid TransactionTooLargeException
to be thrown on Android >= 7.
Something like Ubuntu Disk Usage Analyzer would be helpful - see screeshot:
You can also use this one :-
=> just pass the Bundle here
Then use
android.text.format.Formatter.formatFileSize(activityContext, bytes)
to output nicely.The TooLargeTool is great for analysing bundle size when diagnosing TransactionTooLargeException.