How can I tell if I am out of inotify watches?












42















I use an application that consumes inotify watches. I've already set



fs.inotify.max_user_watches=32768


in /etc/sysctl.conf but last night the application stopped indexing unless I ran it manually, which leads me to suspect I am out of watches.



Since I don't know what the trade off is when I increase this number (does it consume more RAM?), I don't know if I should just increase this number, so I'd like to know if there's a way I can tell if it's using all these watches and what the tradeoffs might be for increasing it.










share|improve this question

























  • This question has become quite relevant again as it turns out in 18.04 unlocking the screen is not possible if one has run out of inode watches.

    – kasperd
    Jan 21 at 21:33
















42















I use an application that consumes inotify watches. I've already set



fs.inotify.max_user_watches=32768


in /etc/sysctl.conf but last night the application stopped indexing unless I ran it manually, which leads me to suspect I am out of watches.



Since I don't know what the trade off is when I increase this number (does it consume more RAM?), I don't know if I should just increase this number, so I'd like to know if there's a way I can tell if it's using all these watches and what the tradeoffs might be for increasing it.










share|improve this question

























  • This question has become quite relevant again as it turns out in 18.04 unlocking the screen is not possible if one has run out of inode watches.

    – kasperd
    Jan 21 at 21:33














42












42








42


22






I use an application that consumes inotify watches. I've already set



fs.inotify.max_user_watches=32768


in /etc/sysctl.conf but last night the application stopped indexing unless I ran it manually, which leads me to suspect I am out of watches.



Since I don't know what the trade off is when I increase this number (does it consume more RAM?), I don't know if I should just increase this number, so I'd like to know if there's a way I can tell if it's using all these watches and what the tradeoffs might be for increasing it.










share|improve this question
















I use an application that consumes inotify watches. I've already set



fs.inotify.max_user_watches=32768


in /etc/sysctl.conf but last night the application stopped indexing unless I ran it manually, which leads me to suspect I am out of watches.



Since I don't know what the trade off is when I increase this number (does it consume more RAM?), I don't know if I should just increase this number, so I'd like to know if there's a way I can tell if it's using all these watches and what the tradeoffs might be for increasing it.







kernel files inotify






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 23 '17 at 12:39









Community

1




1










asked Jun 21 '12 at 17:28









Jorge CastroJorge Castro

36.6k106422617




36.6k106422617













  • This question has become quite relevant again as it turns out in 18.04 unlocking the screen is not possible if one has run out of inode watches.

    – kasperd
    Jan 21 at 21:33



















  • This question has become quite relevant again as it turns out in 18.04 unlocking the screen is not possible if one has run out of inode watches.

    – kasperd
    Jan 21 at 21:33

















This question has become quite relevant again as it turns out in 18.04 unlocking the screen is not possible if one has run out of inode watches.

– kasperd
Jan 21 at 21:33





This question has become quite relevant again as it turns out in 18.04 unlocking the screen is not possible if one has run out of inode watches.

– kasperd
Jan 21 at 21:33










2 Answers
2






active

oldest

votes


















56














How do you know if you are out of watches? tail will tell!




  • Start tail with the -f (follow) option on any old file, e.g. tail -f /var/log/dmesg:


    • If all is well, it will show the last 10 lines and pause; abort with Ctrl-C

    • If you are out of watches, it will fail with this somewhat cryptic error:

      tail: cannot watch '/var/log/dmsg': No space left on device





For the curious: Why is tail a "telltail"?




  • Actually, any well-written app should have the courtesy of telling you, since the inotify API/calls clearly tells them what the deal is.

  • Try strace tail -f ... instead, and when it succeeds, it ends with:


    inotify_add_watch(4, "/var/log/dmesg", IN_MODIFY...) = 1


  • but if it fails, i.e. you are out of watches, it'll say:


    inotify_add_watch(4, "/var/log/dmesg", IN_MODIFY..)
    = -1 ENOSPC (No space left on device)



Can you increase the watches? By how much? Any tradeoffs?



Short answer: Sure, no sweat. Go to straight to a half-million (524288) if you want...the additional memory used should be negligible on a modern system with 4GB+ of memory.




  • Each used inotify watch takes up 540 bytes (32-bit system), or 1 kB (double - on 64-bit) [sources: 1, 2]

  • This comes out of kernel memory, which is unswappable.


  • So, assuming you set the max at 524288, and all were used (improbable), you'd be using approx. 256MB/512MB of 32-bit/64-bit kernel memory




    • Note that your application will also use additional memory to keep track of the inotify handles, file/directory paths, etc. -- how much depends on its design.



  • What's the max value? I guess none, in theory, as long as you have enough RAM. In practice, 524288 has been officially recommended by apps, and people have been setting it to 2 million, with the accompanying memory usage, of course.







share|improve this answer





















  • 4





    If you also want to know the actual current number of inotify watches (thus more then yes/no), go for sudo lsof | grep -i inotify | wc -l

    – Frank Nocke
    Sep 14 '17 at 12:14






  • 2





    "well-written-app" link broken.

    – Gaurav Sharma
    Apr 9 '18 at 7:15



















9














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




  • Dropbox error - 'echo 100000 | sudo tee / proc/sys/fs/inotify/max_user_watches'


  • kernel-inotify-watch-limit-reached







share|improve this answer


























  • Sorry man, I had a draft open yesterday for a few hours and didn't see your answer before I posted mine. I guess it's OK since they have two different approaches :-) Could you just clarify that in recent kernels, inotify uses 0.5KB (on 32-bit) or 1KB (64-bit) of kernel memory per watch, since the old info from 2005 doesn't seem to be true any longer?

    – ish
    Jun 25 '12 at 7:52











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f154255%2fhow-can-i-tell-if-i-am-out-of-inotify-watches%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









56














How do you know if you are out of watches? tail will tell!




  • Start tail with the -f (follow) option on any old file, e.g. tail -f /var/log/dmesg:


    • If all is well, it will show the last 10 lines and pause; abort with Ctrl-C

    • If you are out of watches, it will fail with this somewhat cryptic error:

      tail: cannot watch '/var/log/dmsg': No space left on device





For the curious: Why is tail a "telltail"?




  • Actually, any well-written app should have the courtesy of telling you, since the inotify API/calls clearly tells them what the deal is.

  • Try strace tail -f ... instead, and when it succeeds, it ends with:


    inotify_add_watch(4, "/var/log/dmesg", IN_MODIFY...) = 1


  • but if it fails, i.e. you are out of watches, it'll say:


    inotify_add_watch(4, "/var/log/dmesg", IN_MODIFY..)
    = -1 ENOSPC (No space left on device)



Can you increase the watches? By how much? Any tradeoffs?



Short answer: Sure, no sweat. Go to straight to a half-million (524288) if you want...the additional memory used should be negligible on a modern system with 4GB+ of memory.




  • Each used inotify watch takes up 540 bytes (32-bit system), or 1 kB (double - on 64-bit) [sources: 1, 2]

  • This comes out of kernel memory, which is unswappable.


  • So, assuming you set the max at 524288, and all were used (improbable), you'd be using approx. 256MB/512MB of 32-bit/64-bit kernel memory




    • Note that your application will also use additional memory to keep track of the inotify handles, file/directory paths, etc. -- how much depends on its design.



  • What's the max value? I guess none, in theory, as long as you have enough RAM. In practice, 524288 has been officially recommended by apps, and people have been setting it to 2 million, with the accompanying memory usage, of course.







share|improve this answer





















  • 4





    If you also want to know the actual current number of inotify watches (thus more then yes/no), go for sudo lsof | grep -i inotify | wc -l

    – Frank Nocke
    Sep 14 '17 at 12:14






  • 2





    "well-written-app" link broken.

    – Gaurav Sharma
    Apr 9 '18 at 7:15
















56














How do you know if you are out of watches? tail will tell!




  • Start tail with the -f (follow) option on any old file, e.g. tail -f /var/log/dmesg:


    • If all is well, it will show the last 10 lines and pause; abort with Ctrl-C

    • If you are out of watches, it will fail with this somewhat cryptic error:

      tail: cannot watch '/var/log/dmsg': No space left on device





For the curious: Why is tail a "telltail"?




  • Actually, any well-written app should have the courtesy of telling you, since the inotify API/calls clearly tells them what the deal is.

  • Try strace tail -f ... instead, and when it succeeds, it ends with:


    inotify_add_watch(4, "/var/log/dmesg", IN_MODIFY...) = 1


  • but if it fails, i.e. you are out of watches, it'll say:


    inotify_add_watch(4, "/var/log/dmesg", IN_MODIFY..)
    = -1 ENOSPC (No space left on device)



Can you increase the watches? By how much? Any tradeoffs?



Short answer: Sure, no sweat. Go to straight to a half-million (524288) if you want...the additional memory used should be negligible on a modern system with 4GB+ of memory.




  • Each used inotify watch takes up 540 bytes (32-bit system), or 1 kB (double - on 64-bit) [sources: 1, 2]

  • This comes out of kernel memory, which is unswappable.


  • So, assuming you set the max at 524288, and all were used (improbable), you'd be using approx. 256MB/512MB of 32-bit/64-bit kernel memory




    • Note that your application will also use additional memory to keep track of the inotify handles, file/directory paths, etc. -- how much depends on its design.



  • What's the max value? I guess none, in theory, as long as you have enough RAM. In practice, 524288 has been officially recommended by apps, and people have been setting it to 2 million, with the accompanying memory usage, of course.







share|improve this answer





















  • 4





    If you also want to know the actual current number of inotify watches (thus more then yes/no), go for sudo lsof | grep -i inotify | wc -l

    – Frank Nocke
    Sep 14 '17 at 12:14






  • 2





    "well-written-app" link broken.

    – Gaurav Sharma
    Apr 9 '18 at 7:15














56












56








56







How do you know if you are out of watches? tail will tell!




  • Start tail with the -f (follow) option on any old file, e.g. tail -f /var/log/dmesg:


    • If all is well, it will show the last 10 lines and pause; abort with Ctrl-C

    • If you are out of watches, it will fail with this somewhat cryptic error:

      tail: cannot watch '/var/log/dmsg': No space left on device





For the curious: Why is tail a "telltail"?




  • Actually, any well-written app should have the courtesy of telling you, since the inotify API/calls clearly tells them what the deal is.

  • Try strace tail -f ... instead, and when it succeeds, it ends with:


    inotify_add_watch(4, "/var/log/dmesg", IN_MODIFY...) = 1


  • but if it fails, i.e. you are out of watches, it'll say:


    inotify_add_watch(4, "/var/log/dmesg", IN_MODIFY..)
    = -1 ENOSPC (No space left on device)



Can you increase the watches? By how much? Any tradeoffs?



Short answer: Sure, no sweat. Go to straight to a half-million (524288) if you want...the additional memory used should be negligible on a modern system with 4GB+ of memory.




  • Each used inotify watch takes up 540 bytes (32-bit system), or 1 kB (double - on 64-bit) [sources: 1, 2]

  • This comes out of kernel memory, which is unswappable.


  • So, assuming you set the max at 524288, and all were used (improbable), you'd be using approx. 256MB/512MB of 32-bit/64-bit kernel memory




    • Note that your application will also use additional memory to keep track of the inotify handles, file/directory paths, etc. -- how much depends on its design.



  • What's the max value? I guess none, in theory, as long as you have enough RAM. In practice, 524288 has been officially recommended by apps, and people have been setting it to 2 million, with the accompanying memory usage, of course.







share|improve this answer















How do you know if you are out of watches? tail will tell!




  • Start tail with the -f (follow) option on any old file, e.g. tail -f /var/log/dmesg:


    • If all is well, it will show the last 10 lines and pause; abort with Ctrl-C

    • If you are out of watches, it will fail with this somewhat cryptic error:

      tail: cannot watch '/var/log/dmsg': No space left on device





For the curious: Why is tail a "telltail"?




  • Actually, any well-written app should have the courtesy of telling you, since the inotify API/calls clearly tells them what the deal is.

  • Try strace tail -f ... instead, and when it succeeds, it ends with:


    inotify_add_watch(4, "/var/log/dmesg", IN_MODIFY...) = 1


  • but if it fails, i.e. you are out of watches, it'll say:


    inotify_add_watch(4, "/var/log/dmesg", IN_MODIFY..)
    = -1 ENOSPC (No space left on device)



Can you increase the watches? By how much? Any tradeoffs?



Short answer: Sure, no sweat. Go to straight to a half-million (524288) if you want...the additional memory used should be negligible on a modern system with 4GB+ of memory.




  • Each used inotify watch takes up 540 bytes (32-bit system), or 1 kB (double - on 64-bit) [sources: 1, 2]

  • This comes out of kernel memory, which is unswappable.


  • So, assuming you set the max at 524288, and all were used (improbable), you'd be using approx. 256MB/512MB of 32-bit/64-bit kernel memory




    • Note that your application will also use additional memory to keep track of the inotify handles, file/directory paths, etc. -- how much depends on its design.



  • What's the max value? I guess none, in theory, as long as you have enough RAM. In practice, 524288 has been officially recommended by apps, and people have been setting it to 2 million, with the accompanying memory usage, of course.








share|improve this answer














share|improve this answer



share|improve this answer








edited 7 hours ago









oligofren

348214




348214










answered Jun 24 '12 at 15:17









ishish

116k30267293




116k30267293








  • 4





    If you also want to know the actual current number of inotify watches (thus more then yes/no), go for sudo lsof | grep -i inotify | wc -l

    – Frank Nocke
    Sep 14 '17 at 12:14






  • 2





    "well-written-app" link broken.

    – Gaurav Sharma
    Apr 9 '18 at 7:15














  • 4





    If you also want to know the actual current number of inotify watches (thus more then yes/no), go for sudo lsof | grep -i inotify | wc -l

    – Frank Nocke
    Sep 14 '17 at 12:14






  • 2





    "well-written-app" link broken.

    – Gaurav Sharma
    Apr 9 '18 at 7:15








4




4





If you also want to know the actual current number of inotify watches (thus more then yes/no), go for sudo lsof | grep -i inotify | wc -l

– Frank Nocke
Sep 14 '17 at 12:14





If you also want to know the actual current number of inotify watches (thus more then yes/no), go for sudo lsof | grep -i inotify | wc -l

– Frank Nocke
Sep 14 '17 at 12:14




2




2





"well-written-app" link broken.

– Gaurav Sharma
Apr 9 '18 at 7:15





"well-written-app" link broken.

– Gaurav Sharma
Apr 9 '18 at 7:15













9














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




  • Dropbox error - 'echo 100000 | sudo tee / proc/sys/fs/inotify/max_user_watches'


  • kernel-inotify-watch-limit-reached







share|improve this answer


























  • Sorry man, I had a draft open yesterday for a few hours and didn't see your answer before I posted mine. I guess it's OK since they have two different approaches :-) Could you just clarify that in recent kernels, inotify uses 0.5KB (on 32-bit) or 1KB (64-bit) of kernel memory per watch, since the old info from 2005 doesn't seem to be true any longer?

    – ish
    Jun 25 '12 at 7:52
















9














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




  • Dropbox error - 'echo 100000 | sudo tee / proc/sys/fs/inotify/max_user_watches'


  • kernel-inotify-watch-limit-reached







share|improve this answer


























  • Sorry man, I had a draft open yesterday for a few hours and didn't see your answer before I posted mine. I guess it's OK since they have two different approaches :-) Could you just clarify that in recent kernels, inotify uses 0.5KB (on 32-bit) or 1KB (64-bit) of kernel memory per watch, since the old info from 2005 doesn't seem to be true any longer?

    – ish
    Jun 25 '12 at 7:52














9












9








9







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




  • Dropbox error - 'echo 100000 | sudo tee / proc/sys/fs/inotify/max_user_watches'


  • kernel-inotify-watch-limit-reached







share|improve this answer















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




  • Dropbox error - 'echo 100000 | sudo tee / proc/sys/fs/inotify/max_user_watches'


  • kernel-inotify-watch-limit-reached








share|improve this answer














share|improve this answer



share|improve this answer








edited Apr 13 '17 at 12:37









Community

1




1










answered Jun 24 '12 at 10:13









Bruno PereiraBruno Pereira

60.2k26179208




60.2k26179208













  • Sorry man, I had a draft open yesterday for a few hours and didn't see your answer before I posted mine. I guess it's OK since they have two different approaches :-) Could you just clarify that in recent kernels, inotify uses 0.5KB (on 32-bit) or 1KB (64-bit) of kernel memory per watch, since the old info from 2005 doesn't seem to be true any longer?

    – ish
    Jun 25 '12 at 7:52



















  • Sorry man, I had a draft open yesterday for a few hours and didn't see your answer before I posted mine. I guess it's OK since they have two different approaches :-) Could you just clarify that in recent kernels, inotify uses 0.5KB (on 32-bit) or 1KB (64-bit) of kernel memory per watch, since the old info from 2005 doesn't seem to be true any longer?

    – ish
    Jun 25 '12 at 7:52

















Sorry man, I had a draft open yesterday for a few hours and didn't see your answer before I posted mine. I guess it's OK since they have two different approaches :-) Could you just clarify that in recent kernels, inotify uses 0.5KB (on 32-bit) or 1KB (64-bit) of kernel memory per watch, since the old info from 2005 doesn't seem to be true any longer?

– ish
Jun 25 '12 at 7:52





Sorry man, I had a draft open yesterday for a few hours and didn't see your answer before I posted mine. I guess it's OK since they have two different approaches :-) Could you just clarify that in recent kernels, inotify uses 0.5KB (on 32-bit) or 1KB (64-bit) of kernel memory per watch, since the old info from 2005 doesn't seem to be true any longer?

– ish
Jun 25 '12 at 7:52


















draft saved

draft discarded




















































Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f154255%2fhow-can-i-tell-if-i-am-out-of-inotify-watches%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Category:香港粉麵

List *all* the tuples!

Channel [V]