简体   繁体   中英

Why “avoid passing large objects through Binder”?

I'm reading Google's "Developing for Android" series on Medium -- https://medium.com/google-developers/developing-for-android-vii-the-rules-framework-concerns-d0210e52eee3

In the Framework chapter, it says "Avoid Passing Large Objects Through Binder -- Objects are copied as they are serialized through the Binder, so the larger the object, the longer the process of passing it through."

I'm not sure I understand this entirely. When does this happen? When I pass data between activities, is this applicable to that?

Activity is not a Binder, pass data between activities in one app not problem. when you pass data between processes, like between activity or service in different apps, avoid the large objects.

Every process has an associated binder buffer of size 1 MB. All transactions, a process has with other processes use this buffer. So, naturally we should avoid passing very large objects via binder, serializing the object for transfer will take more time, plus the transaction could even fail due to size constraints, giving TransactionTooLargeException, http://developer.android.com/reference/android/os/TransactionTooLargeException.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM