Linux中文件描述符的上限

前端之家收集整理的这篇文章主要介绍了Linux中文件描述符的上限前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
可以在任何 Linux系统(特别是ubuntu 10.04)中使用的文件描述符的上限是多少?

我使用Ubuntu 10.04(64位),服务器的cpu架构是x86_64,客户端是i686.现在我把我的fd限制提高到了40万.

>使用大号的可能的副作用是什么?的文件描述符?
>我怎么知道不.任何进程使用的文件描述符?

日Thnx

解决方法

你想看看/ proc / sys / fs / file-max.

从最近的linux / Documentation / sysctl / fs.txt:

file-max and file-nr:

The kernel allocates file handles dynamically,but as yet it doesn’t
free them again.

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.

Historically,the three values in file-nr denoted the number of
allocated file handles,the number of allocated but unused file
handles,and the maximum number of file handles. Linux 2.6 always
reports 0 as the number of free file handles — this is not an error,
it just means that the number of allocated file handles exactly
matches the number of used file handles.

Attempts to allocate more file descriptors than file-max are reported
with printk,look for “VFS: file-max limit reached”.

2.6内核使用经验法则来根据系统中的内存量来设置file-max. 2.6内核中fs / file_table.c的片段:

/*
 * One file with associated inode and dcache is very roughly 1K.
 * Per default don't use more than 10% of our memory for files. 
 */ 

n = (mempages * (PAGE_SIZE / 1024)) / 10;
files_stat.max_files = max_t(unsigned long,n,NR_FILE);

files_stat.max_files是fs.file-max的设置.对于每1公斤的公羊,最终大约为100(10%)

猜你在找的Linux相关文章