• linux 最大文件打开数nofile及nr_open、file-max说明


    1./etc/security/limits.conf中指定的nofile的值,nofile有上限,不是无穷大。nofile由内核参数nr_open定义的.

    “在2.6.25内核之前有个宏定义,定义了这个值的最大值,为1024*1024,正好是100万,而在2.6.25内核及其之后,这个值是可以通过/proc/sys/fs/nr_open来设置。”

    2.使用cat /proc/sys/fs/nr_open 查看nr_open值,可通过修改/ect/sysct.conf 修改fs.nr_open值,sysctl -p生效

    3.fix_max linux内核定义的最大file handles(文件句柄数).nr_open定义是单进程最大file-handles,file-handles(即文件句柄)

    file-max:
    The value in file-max denotes the maximum number of file-
    handles that the Linux kernel will allocate. When you get lots
    of error messages about running out of file handles, you might
    want to increase this limit
     
     
    nr_open:
    This denotes the maximum number of file-handles a process can
    allocate. Default value is 1024*1024 (1048576) which should be
    enough for most machines. Actual limit depends on RLIMIT_NOFILE
    resource limit.

    4.file-handles与fd

    在UNIX/LINUX中我们接触更多是file discriptor(FD,即文件描述符),通过百度搜索,似乎file-handle在windows中是一个类似file discrptor的东东,但是我们讨论的是linux,再google一下,我们可以精确到c语言中这两个概念的区别,据他们的讨论file-handle应该是一个高层的对象,使用fopen,fread等函数来调用,而FD是底层的一个对象,可以通过open,read等函数来调用。

  • 相关阅读:
    UGUI Toggle控件
    UGUI Scrollbar控件
    利用头插法——创建、遍历链表
    函数指针
    opencv 图像通道操作
    三维点云匹配算法
    点与三角形位置关系
    室内场景mesh 的自动分块---用于加载显示,参数化等
    eigen 四元数
    string 、char*、const char *
  • 原文地址:https://www.cnblogs.com/cheyunhua/p/14205863.html
Copyright © 2020-2023  润新知