Created
June 15, 2013 14:44
-
-
Save felixyz/5788375 to your computer and use it in GitHub Desktop.
MRI pipe limit (on OS X). This script fails on my Mac after creating 125 x 2 pipe endpoints, raising "Too many open files (Errno::EMFILE)" This is the cause of the problem illustrated here: https://gist.github.com/Felixyz/5788285
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wakeups = [] | |
wakers = [] | |
puts "Creating pipes..." | |
200.times do |n| | |
puts "[#{n}]" | |
wakeup, waker = IO.pipe | |
wakeups << wakeup | |
wakers << waker | |
end | |
puts "Closing pipes..." | |
wakeups.each {|pipe| pipe.close rescue nil} | |
wakers.each {|pipe| pipe.close rescue nil} |
Interesting to note that JRuby copes even with a small ulimit -n value.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just in case anyone stumbles upon this: the problem is the OS limit on open files, as seen by running ulimit -a
Seems the default value has been increased btw 10.8.2 and 10.8.4. In any case, raising the number of allowed file descriptors solves the problem. (http://superuser.com/questions/261023/how-to-change-default-ulimit-values-in-mac-os-x-10-6)