How to tune inotify to use less memory?

I'm working on an embedded linux system.

I tried to use inotify to monitor changes. But when I tried to monitor a huge numbers of folders (let's say more than 6000 folders), inotify uses a lot of memory (about 25-30MB). As you all know, 25-30MB in embedded system is considered to be large...

My questions are;

  • is this normal?
  • is anyone know how to tune this?
  • any alternative to monitor a huge numbers of folders without adding watch in each folder?

Answers


As far as I know a recursive watch is not possible with an unpatched Linux kernel. See also http://superuser.com/questions/118642/recursive-filesystem-notifications-inotify-for-ubuntu-karmic-koala . Maybe fanotify would work for you, but it needs a kernel patch.


Look into using Auditd.

There is also a user space file system called loggedfs, but I couldn't get that to work.


It's inevitable to monitor directories recursively when using inotify. reference: http://en.wikipedia.org/wiki/Inotify#Limitations

In order to improve inotify(7) performance(reduce memory usage, maybe), my suggestion is: Whenever you start watching a directory, just focus on types of inotify_event that interest you(as less as possible), you can adjust the mask argument of inotify_add_watch(2) function to achieve this. Setting the mask argument value to IN_ALL_EVENTS to monitor all kinds to inotify_event is sometimes unnecessary.

Hope this helps.


Need Your Help

crc24 from c to python

python c translation port

can someone please translate this code to python? i have tried and tried again, but have not managed it:

Window width and resize

javascript jquery

I would like to calculate the number of icons e.g. 50px depending on the width of the window for a menu.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.