简体   繁体   中英

Understand BINDER_VM_SIZE in Android source code

In file framework/native/libs/binder/ProcessState.cpp

Why is BINDER_VM_SIZE set to 1M-8k?

#define BINDER_VM_SIZE ((1*1024*1024) - (4096 *2)) 

It's not this value initially, you can find that(from git commit log) it's first value is

#define BINDER_VM_SIZE (1*1024*1024)

Then someone change this value to

#define BINDER_VM_SIZE ((1*1024*1024) - (4096 *2)) 

with the following commit message:

Modify the binder to request 1M - 2 pages instead of 1M. The backing store in the kernel requires a guard page, so 1M allocations fragment memory very badly. Subtracting a couple of pages so that they fit in a power of two allows the kernel to make more efficient use of its virtual address space.

I myself don't fully understand this message,so I just paste it here hope it may help your understanding!

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