如何在Mb中记录我的Bundle的大小?

问题描述 投票:0回答:1

我有时在TransactionTooLargeException得到onSaveInstanceState。所以,我假设我的Bundle太大的大小导致了这一点。我想记录它的精确/近似大小,以便我可以粗略估计我需要的数量,以尽量减少它。

现在,我能找到它的大小的唯一方法是当TransactionTooLargeException被抛出时

E/JavaBinder: !!! FAILED BINDER TRANSACTION !!!  (parcel size = 1026104)
D/AndroidRuntime: Shutting down VM
I/art: Compiler allocated 6MB to compile void com.example.ExampleModel.writeToParcel(android.os.Parcel, int)
E/UncaughtException: java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 1026104 bytes
android android-lifecycle parcelable android-bundle
1个回答
0
投票

please click here for reference

要利用Dex In Process,您需要修改gradle.properties文件,并使用org.gradle.jvmargs属性将分配给Gradle Daemon VM的内存量增加1 Gb,最小值为2 Gb :

org.gradle.jvmargs = -Xmx2048m

© www.soinside.com 2019 - 2024. All rights reserved.