Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If fs.file-max is not set in /etc/sysctl.conf on RHEL 5 or its derivatives, how does the kernel determine the default value? Is there a formula used to set the fs.file-max value based on the amount of system RAM? I checked a number of random RHEL servers running the same OS level, but with different hardware configurations, and cat /proc/sys/fs/file-max shows different values on each system.

share|improve this question
up vote 3 down vote accepted

I'll answer my own question: the Linux 2.6 kernel sets the open file limit to 10% of the available memory.


 488 void __init files_init(unsigned long mempages)
 489 { 
 490         int n; 
 492         filp_cachep = kmem_cache_create("filp", sizeof(struct file), 0,
 493                         SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL);
 495         /*
 496          * One file with associated inode and dcache is very roughly 1K.
 497          * Per default don't use more than 10% of our memory for files. 
 498          */ 
 500         n = (mempages * (PAGE_SIZE / 1024)) / 10;
 501         files_stat.max_files = n; 
 502         if (files_stat.max_files < NR_FILE)
 503                 files_stat.max_files = NR_FILE;
 504         files_defer_init();
 505         lg_lock_init(files_lglock);
 506         percpu_counter_init(&nr_files, 0);
 507 } 
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.