Getting java.nio.file.FileSystemException: "Too many open files" when I build my Java project on IntelliJ Idea

Answered

I already tried following:

$ sudo sysctl -w kern.maxfiles=200000
$ sudo sysctl -w kern.maxfilesperproc=200000
$ ulimit -n 20480
$ sudo sysctl -w kern.ipc.somaxconn=2048

I also tried adding limit.maxfiles.plist to ~/Library/LaunchDaemons

<?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>262144</string>
<string>262144</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceIPC</key>
<false/>
</dict>
</plist>

Also, Added limits.conf to ~/etc/Library

* hard nofile 65535
* soft nofile 65535

 

None of this helped. Any help is greatly appreciated.

Stacktrace:

INFO - rains.jps.cmdline.BuildSession - java.nio.file.FileSystemException: /Users/user/Library/Caches/JetBrains/IntelliJIdea2021.1/compile-server/adb9b964/timestamps/data.values.at: Too many open files
java.lang.RuntimeException: java.nio.file.FileSystemException: /Users/user/Library/Caches/JetBrains/IntelliJIdea2021.1/compile-server/adb9b964/timestamps/data.values.at: Too many open files
0
5 comments

We don't have any other suggestions beyond what you can Google yourself like https://superuser.com/questions/433746/is-there-a-fix-for-the-too-many-open-files-in-system-error-on-os-x-10-7-1.

How many open files are there actually when this issue occurs?

lsof -n +c 0 | sed -E 's/^([^ ]+[ ]+[^ ]+).*$/\1/' | uniq -c | sort | tail
0

Maybe 20480 ulimit is too small and overrides the other settings? Try to be consistent with the values. Otherwise the settings you make probably don't have effect for some reason.

0

What should be the ideal value there?

0

Depends on the project size and on the total number of the open files. I would try 60000.

0

I also just had this issue.

checking relevant processes with

sudo lsof -n | cut -f1 -d' ' | uniq -c | sort | tail

turned out that “language_” had more than 230000 (yes 6 digit) files open, while

sysctl kern.maxfiles

sysctl kern.maxfilesperproc

was only slightly above that and the next action (e.g. opening a web browser) would stall…

it seems to be gone after I uninstalled the Fig plugin in Webstorm

0

Please sign in to leave a comment.