How much memory could vm use

后端 未结 3 1920
走了就别回头了
走了就别回头了 2020-12-13 05:26

I read the document Understanding Virtual Memory and it said one method for changing tunable parameters in the Linux VM was the command:

sysctl -w vm.max_map         


        
相关标签:
3条回答
  • 2020-12-13 06:17

    From the Linux kernel documentation:

    max_map_count:

    This file contains the maximum number of memory map areas a process may have. Memory map areas are used as a side-effect of calling malloc, directly by mmap and mprotect, and also when loading shared libraries.

    While most applications need less than a thousand maps, certain programs, particularly malloc debuggers, may consume lots of them, e.g., up to one or two maps per allocation.

    The default value is 65536.

    Bottom line: this setting limits the number of discrete mapped memory areas - on its own it imposes no limit on the size of those areas or on the memory that is usable by a process.

    And yes, this:

    sysctl -w vm.max_map_count=65535
    

    is just a nicer way of writing this:

    echo 65535 > /proc/sys/vm/max_map_count
    
    0 讨论(0)
  • 2020-12-13 06:18
    echo "vm.max_map_count=262144" >> /etc/sysctl.conf
    sysctl -p
    

    This does not work since we cannot change the configuration file directly. Run the below command.

    echo vm.max_map_count=262144 | sudo tee -a /etc/sysctl.conf
    

    But check if vm.max_map_count already exists or not. You can do that using

    cat /etc/sysctl.conf | grep vm.max_map_count
    
    0 讨论(0)
  • 2020-12-13 06:26
    echo 'vm.max_map_count=262144' >> /etc/sysctl.conf
    
    sysctl -p
    
    0 讨论(0)
提交回复
热议问题