Platform independent ulimit number of open files increase

Why increase ulimit -n maximum number of open files?

Making Matplotlib/Seaborn plots in parallel executing threads in Python is one area where you may need to increase ulimit -n setting. That is, increase the limit for the maximum number of open files. The default maximum number of open file limits are a bit low

Linux (Ubuntu) Mac OS X (Yosemite/El Capitan)
1024 256

This can lead to errors from Python with Matplotlib like:

OSError: [Errno 24] Too many open files: ‘/usr/share/fonts/truetype/msttcorefonts/arial.ttf’

Fix too many open files error with Ulimit increase

Platform independent ulimit -n increase

In general I avoid one-off or sudo-requiring system parameter setting techniques, and would defer to using platform-independent Python since virtually all of my programs at least incidentally use Python. This does not use sudo. It instead makes temporary setting changes where feasible or at most user-profile specific system changes. This change will be only for this instance of Python; once Python terminates even the same terminal session will have the original ulimit again.

Leave a Comment