I don't know if I should just increase this number
The easy way of checking if you reached your max_user_watches
value is, with your user, to use inotifywatch
, from the package inotify-tools
, and check if you can still collect information from a file.
For example inotifywatch -v /home/bruno/.profile
for me returns:
Establishing watches...
Total of 1 watches.
Finished establishing watches, now collecting statistics.
So inotify
has no issues creating a new watch, no issues here.
If you have reached your maximum limit in inotify watches it will return something like
Failed to watch /home/bruno/.profile; upper limit on inotify watches reached!
If you see something like this then you have reached the limit and will need to increase the allowed watches limit.
Does it consume more RAM?
Yes, it does. But according to this old article the amount it consumes is minimal compared with other aspects of a running desktop.
--MEMORY USAGE--
The inotify data structures are light weight:
inotify watch is 40 bytes
inotify device is 68 bytes
inotify event is 272 bytes
So assuming a device has 8192 watches, the structures are only going
to consume 320KB of memory. With a maximum number of 8 devices allowed
to exist at a time, this is still only 2.5 MB
Each device can also have 256 events queued at a time, which sums to
68KB per device. And only .5 MB if all devices are opened and have
a full event queue.
So approximately 3 MB of memory are used in the rare case of
everything open and full.
Each inotify watch pins the inode of a directory/file in memory,
the size of an inode is different per file system but lets assume
that it is 512 byes.
So assuming the maximum number of global watches are active, this would
pin down 32 MB of inodes in the inode cache. Again not a problem
on a modern system.
I am of course assuming things did not change a lot since the article was written but looking at the numbers I would not worry and increasing the limit will not increase RAM consumption by much.
Related posts about inotify