Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Whilst writing some unit tests I hit the upper limit for too many open files (Debian VM) - "failed to open stream: Too many open files"

Other than a restart, is there any way to clear this block? (i.e. will these open, but unaccessed, files be cleaned up over time?)

Fyi - I'd like to know because I want to setup a continuous integration server for unit testing, and if a reboot is the only way to clear this problem then I need to find a different way of approaching certain unit tests.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

Not unless you close them or the process that owns them dies.

It's possible that the user that you are using to run the tests is constrained by ulimits as to how many files they can open.

share|improve this answer

Did you try to increase the maximum open files for the user under which you run the tests ?

To see how many open files the user has (soft and hard):

# ulimit -Hn
# ulimit -Sn

Also it normal that sometimes you need to increase the global max open files for the system. So try with that and find out if it helps.

# sysctl -w fs.file-max=100000

If you wanna permanently change the max open files you need to edit /etc/sysctl.conf file and add/change the following line

fs.file-max = 100000
share|improve this answer

Your Answer

 
discard

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.