سؤال

In my application I have different modules which communicate through posix queues, the problem is Im getting the above mentioned error when limit meets, I have set the limit in both

sysctl fs.file-max = new_value 

and

ulimit -n 

but this is some hardcoded value, is there any best practice to overcome this? I tried closing the descriptors by mq_close but then again all the modules in application can use any message at any time. So I cannot close all the descriptors.

هل كانت مفيدة؟

المحلول

There are two types of resource limits in linux/UNIX Soft limit & Hard limit. The maximum descriptors you can set is up to the hard limit. There are methods to increase hard limit but frankly speaking I have never tried so & neither I would recommend this due to two reasons:

  1. Opening too many descriptors concurrently will slow down the performance of your program.
  2. It is not even required to increase hard limit since if you close the unused descriptors properly in your program you will see yourself that it is not even required. Imagine a web server that opens a new descriptor for every new request also does not require to increase the hard limit.

Finally I would recommend you even to increase the soft limit please use setrlimit function from your program since increasing the limit on the shell is temporary & if you set it in profile it will increase the limit for all the programs.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top