MATLAB: How to resolve ulimit related issues in R2017a on macOS Sierra

MATLAB

How do I increase the ulimit permanently on macOS to resolve issues related to the default ulimit on Sierra?

Best Answer

This issue has been resolved as of MATLAB R2017b.
For releases prior to MATLAB R2017b, the default ulimit is set to 256 on macOS. In previous releases of MATLAB our launch scripts would temporarily increase the ulimit for the session to prevent the MATLAB instance from encountering the low limit. In R2017a, we no longer have such a script in place when MATLAB is launched from the application bundle or the dock. To avoid these issues, you will need to set the ulimit to a higher number, for instance 1024. In order to ensure that the change in ulimit persists across reboots please attempt the following workaround:
In Library/LaunchDaemons create a file named limit.maxfiles.plist and paste the following in:
1.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxfiles</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
<string>maxfiles</string>
<string>1024</string>
<string>unlimited</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceIPC</key>
<false/>
</dict>
</plist>
*Note: 1024 was arbitrarily picked, please increase as necessary.
2. Change the owner of your new file:
sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist
3. Load these new settings:
sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist
Finally reboot your machine and verify that your ulimit has increased in terminal by running the command "ulmit -Sn". Assuming it has you should be able to start MATLAB without issue.