inotify¶
Control the maximum number of watchers.
- Increasing the amount of inotify watchers (gist.github.com)
 - inotify-consumers · fatso83/dotfiles generates reports on who's using watchers
 
inotify watcher count limit¶
Check current limits:
$ sysctl fs.inotify
fs.inotify.max_queued_events = 16384
fs.inotify.max_user_instances = 128
fs.inotify.max_user_watches = 409600
Count opened files:
Increase the limit:
echo fs.inotify.max_user_watches=524288 | 
  sudo tee /etc/sysctl.d/40-max-user-watches.conf && 
  sudo sysctl --system
Check who's using them all:
$ bin/inotify-consumers 
   INOTIFY   INSTANCES
   WATCHES      PER   
    COUNT     PROCESS   PID USER         COMMAND
------------------------------------------------------------
   26730         1        2815 m           /usr/bin/syncthing serve --no-browser --logfile=default
    5374         1        3900 m           /usr/libexec/tracker-miner-fs-3
<snip>
   35051  WATCHES TOTAL COUNT
INotify instances per user (e.g. limits specified by fs.inotify.max_user_instances): 
INSTANCES    USER
-----------  ------------------
65           m
/proc interfaces
     The following interfaces can be used to limit the amount of
     kernel memory consumed by inotify:
     /proc/sys/fs/inotify/max_queued_events
            The value in this file is used when an application calls
            inotify_init(2) to set an upper limit on the number of
            events that can be queued to the corresponding inotify
            instance.  Events in excess of this limit are dropped, but
            an IN_Q_OVERFLOW event is always generated.
     /proc/sys/fs/inotify/max_user_instances
            This specifies an upper limit on the number of inotify
            instances that can be created per real user ID.
     /proc/sys/fs/inotify/max_user_watches
            This specifies an upper limit on the number of watches
            that can be created per real user ID.