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

85 out of 94 found this helpful
11 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.

 

1

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`
 

1

@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

Thanks for the updates to this page.

I my case I've been working with a monorepo and I had to increase the value every now and then.

Regarding the maximum theoretical limit for fs.inotify.max_user_watches, this post seems to have the answer:

Regards

0

My Inotify seems to be watching all node_modules in an angular project. It immediately reaches the watch limit every time I start up the application. Is there any way to ignore some folders?

1

@Arthur Pannecoucke Unfortunately no. You can vote for the related issue here: https://youtrack.jetbrains.com/issue/IJPL-2175

0

I had exactly the same problem as Arthur above. Although my `node_modules` folder was already orange, I realized that it did not appear in the list of excluded folders. Adding it solved the problem for me.

Arthur Pannecoucke Could you check, if your `node_modules` does appear in the list of excluded folders?

I have asked a question on StackOverflow about this: https://stackoverflow.com/questions/78648842

0

Hi Watchduck

Wich excluded folders do you mean exactly? 

It's in my gitignore. I see the setting you changed in pycharm (from your stackoverflow post) but I can't find a simialar setting in intelliJ. 

Edited by Arthur Pannecoucke
0

Thanks for the great article, however, even after I set the config per the article, I still get the notification and eventually turn off the file watcher. I'm on remote goland, is there any config that I'm missing ? 
Goland : GoLand 2023.3.6
JetBrains Gateway 2024.1.2
 

0

Haojun you might need to set an even higher value.

In my case I started with the advised value from the article (which incidentally also got gradually increased, even very recently I believe).

For example this are the current settings on my machine (the value can be much higher if needed, see my post above):

$ sysctl fs.inotify.max_user_watches
fs.inotify.max_user_watches = 1500000

Try to experiment by increasing the value by some ratio, maybe by +50%.

Regards

Edited by Mbosi
0

Please sign in to leave a comment.

Have more questions?

Submit a request