[Android Development] Parcel in Binder

Parcel in Binder

What is Parcel

Parcel is an intelligent data container.
Parcel provides the ability to package various types of data or object references in process A, implement cross-process transmission through Binder, and then unpack them in process B.
Parcel automatically completes the packaging and decompression process.

If Parcel is used in the same process, the object data will be disassembled first, copied to Parcel's memory, and then another object will be created based on each field from the parcel's memory, and then the Parcel memory will be released. Therefore, using parcel in the same process will cause memory waste and lower efficiency.

If Parcel is used between different processes, process A will first disassemble the object data and copy it to the Parcel memory, and then copy the data in the Parcel memory to the kernel space to release the Parcel memory. Based on mmap, process B reads data directly from the kernel space, obtains the Parcel object in process B, and then restores and creates a Student object based on each field from the Parcel object. At this time, the Student object is in process B.

Guess you like

Origin blog.csdn.net/qq_39441603/article/details/125963052