linux--句柄相关

一、修改文件句柄数

1.1.查看当前大小

ulimit -a

在这里插入图片描述

1.2.临时修改

ulimit -n 4096

在这里插入图片描述

1.3.永久修改

vim /etc/security/limits.conf

*  soft  nofile  65536

*  hard  nofile  65536

在这里插入图片描述

二、调整vm.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.”

       max_map_count文件包含限制一个进程可以拥有的VMA(虚拟内存区域)的数量。虚拟内存区域是一个连续的虚拟地址空间区域。在进程的生命周期中,每当程序尝试在内存中映射文件,链接到共享内存段,或者分配堆空间的时候,这些区域将被创建。调优这个值将限制进程可拥有VMA的数量。限制一个进程拥有VMA的总数可能导致应用程序出错,因为当进程达到了VMA上线但又只能释放少量的内存给其他的内核进程使用时,操作系统会抛出内存不足的错误。如果你的操作系统在NORMAL区域仅占用少量的内存,那么调低这个值可以帮助释放内存给内核用。

max_map_count文件包含限制一个进程可以拥有的VMA(虚拟内存区域)的数量

报错“max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]”

2.1.查看当前值

sysctl -a|grep vm.max_map_count

在这里插入图片描述

2.2.临时修改

sysctl -w vm.max_map_count=262144

在这里插入图片描述

2.3.永久修改

vim /etc/sysctl.conf

vm.max_map_count=262144

在这里插入图片描述

sysctl -p
原文地址:https://www.cnblogs.com/juniorMa/p/14029502.html