What’s the maximum number of
mmap()‘ed ranges that a process can makes and how to set the limits on Linux?
Internal kernel structures could not be allocated.
Addresses in the range [addr, addr+len-1] are invalid for the address space of the process, or specify one or more pages that are
I am sure that the
mprotect()ed range is mapped and valid. So the problem is the first situation: internal kernel structure allocation failed.
That question is what is the limit here and how to enlarge the limit?
There is a kernel parameter
vm.max_map_count that controls the number of ranges that you can
You can find the current limit by
$ sysctl vm.max_map_count
On my system, the default value is 65530:
vm.max_map_count = 65530
To change the maximum number of mapped ranges allowed to some number such as 655300:
# sysctl -w vm.max_map_count=655300
This changes the runtime parameter of the Linux kernel. To make the change permanent to take effect every time the Linux is rebooted, add a like to the
/etc/sysctl.conf file like