Android security Model Android security mechanism (memory management)

Source: Internet
Author: User

Ashmem Anonymous Shared memory

The Anonymous shared memory (ASHMEM) mechanism of Android is based on the shared memory of the Linux kernel, but the ASHMEM is associated with the cache Shrinker, increasing the registration interface of the memory reclamation algorithm, so that the Linux memory management system will no longer be recycled using the memory area. The ASHMEM is implemented in kernel-driven form and creates/dev/ashmem device files in the file system. If process A and process B require shared memory, process a can open the file by opening and set the name and size of the shared memory with the IOCTL command Ashmem_set_name and Ashmem_set_size. MMAP uses handle to obtain a shared memory area, and process B uses the same handle, which is used by mmap to obtain the same piece of memory. The transfer of handle between processes can be achieved by means of binders.

For a valid recycle, the owner of the memory area is required to notify the Ashmem driver. Through the coordination of the user, the Ashmem driver, and the Linux memory management system, the memory management is more suitable to the embedded mobile device memory less characteristics. The ASHMEM mechanism assists the memory management system to effectively manage memory that is no longer in use, while simultaneously using binder process communication mechanisms to realize memory sharing between processes.

Ashmem not only adapts to Linux developers in the form of/dev/ashmem device files, but also provides access to the Android system runtime and the application framework layer. In the system runtime, the C + + call interface is provided, and the Java calling interface is provided at the application framework layer. In fact, the Java calling interface of the application framework layer is invoked through the JNI method to invoke the C/s + + Call interface of the system runtime, and finally into the Ashmem driver of the kernel space.

LMK mechanism



Android security Model Android security mechanism (memory management)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.