Inotify Watches Limit (Linux)

For an intelligent IDE, it is essential to be in the know about any external changes in files it working with - e.g. changes made by VCS, or build tools, or code generators, etc. For that reason, the IntelliJ platform spins a background process to monitor such changes. The method it uses is platform-specific, and on Linux, it is the Inotify facility.

Inotify requires a "watch handle" to be set for each directory in the project. Unfortunately, the default limit of watch handles may not be enough for reasonably sized projects, and reaching the limit will force IntelliJ platform to fall back to recursive scans of directory trees.

To prevent this situation it is recommended to increase the watches limit (to, say, 1048576):

  1. Add the following line to a new *.conf file (e.g. idea.conf) under /etc/sysctl.d/ directory:
    fs.inotify.max_user_watches = 1048576
  2. Then run this command to apply the change:
    sudo sysctl -p --system

And don't forget to restart your IDE.

Note: the watch limit is per-account setting. If there are other programs running under the same account that also use inotify, the limit should be raised high enough to suit the needs of all of them.

Additional Information

Viewing the current setting: sysctl fs.inotify.max_user_watches

How many inotify watch handles are currently in use by which process: https://stackoverflow.com/a/60705427

Inotify memory usage: https://github.com/torvalds/linux/commit/92890123749bafc317bbfacbe0a62ce08d78efb7

66 out of 74 found this helpful
3 comments

Insite Linux there are a lot of /etc/ folders which one do you mean. what should be before …./etc/sysclt.d/ even when I search at sysctl.d there are many.

 

0

if you see the value different from the one you've set, check the output of  `sudo sysctl -p --system`. It shows where it takes its value from. In my case it was:

* Applying /etc/sysctl.d/10-user-watches.conf ...
fs.inotify.max_user_watches = 1048576

and then:

* Applying /usr/lib/sysctl.d/30-tracker.conf ...
fs.inotify.max_user_watches = 65536

so I renamed `10-user-watches.conf` to `50-user-watches.conf`
 

0

@John Hi, it's /etc/sysclt.d/. There is no path prefix before the /etc/sysclt.d/. There is only one /etc/sysclt.d/ in each Linux system. You could open a file manager on Linux, enter /etc/sysclt.d/ to go there. Or use cd /etc/sysclt.d/ to go to that folder on Linux from Terminal/shell.

0

Please sign in to leave a comment.

Have more questions?

Submit a request