If you get an error “max virtual memory areas vm.max_map_count 65530 is too low increase to at least” when execute the SonarQube or Elastic Search in docker container in Linux instance:
Error: Docker max virtual memory areas vm.max_map_count 65530 is too low increase to at least
vm.max_map_count
vm.max_map_count is a Linux kernel setting that determines the maximum number of memory map areas that a process can have. Memory map areas are used to map files or devices into a process’s memory space, allowing the process to access the data in those files or devices as if they were part of its own memory.
The vm.max_map_count setting is used to prevent a process from consuming too many memory map areas, which could lead to resource exhaustion and system instability. By default, the vm.max_map_count setting is set to 65536 on most systems, but it can be adjusted to meet the needs of the system and the processes running on it.
To check the current value of vm.max_map_count on your system, you can run the following command:
# cat /proc/sys/vm/max_map_count
You need to increase the max_map_count the value in Kernel paramenter that would avoid running out of map areas for the Vector Server process. Memory map areas are used as a side-effect of calling malloc, directly by mmap, mprotect, and madvise, and also when loading shared libraries and the default value is 65536.
We have few more options to set the value in your Linux machine for both CentOS and Ubuntu.
Can update the value to max_map_count file directly using the command below:
# echo 262144 > /proc/sys/vm/max_map_count
or execute the command below:
# echo vm.max_map_count=262144 >> /etc/sysctl .conf
To change the value of vm.max_map_count, you can use the sysctl command as well to set it to the desired value:
# sudo sysctl -w vm.max_map_count=262144
Note that changes made to vm.max_map_count using the sysctl command are temporary and will not persist after a reboot. To make the change permanent, you will need to edit the /etc/sysctl.conf file and add the following line:
reload the configuration settings as root user:
# sysctl -p
It is important to carefully consider the value of vm.max_map_count, as setting it too low can cause processes to fail due to insufficient memory map areas, while setting it too high can lead to resource exhaustion and system instability. It is generally recommended to set vm.max_map_count to a value that is appropriate for the needs of the system and the processes running on it.