Important: Please read the Qt Code of Conduct -

Which is less costly in terms of memory, QFileSystemWatcher or inotify ??

  • Hi,
    I want to make an C++ application that will monitor file changes in its directory or its sub-directories in linux. I know inotify in linux and QFileSystemWatcher can monitor single level directory changes and need to manually add a watch for each sub-directory to detect changes in the sub-directory.

    I need to know which is more memory efficient, using inotify with QT or QFileSystemWatcher to monitor directory changes on linux

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    AFAIK QFileSystemWatcher uses inotify for it's linux implementations so the functionality in itself is the same. The best thing to do is to make some tests to see which one fits the best for your use case.

  • Thank you but I need to monitor directory recursively. Please correct me if i am wrong but if i use QFileSystemWatcher would it cost me more memory since QT need additional calls to use inotify

  • Lifetime Qt Champion

    In terms of pure memory, indeed, it will cost a bit more.

  • Thank your reply.

  • Will QFileSystemWatcher be replaced by some other file monitoring interface in the newer versions of QT ??
    If yes, then will the new interface still use inotify to monitor file and directory changes or will it use some other Linux functionality.

  • Why is that relevant? If it is really that critical you might think of using something else (your own implementation for example) or if still not sufficient a completely different system at all.

  • Lifetime Qt Champion

    Why would it need to be replaced ? It does the job well. If you would like to support another system than you can create your own backend for QFileSystemWatcher.

  • Sorry, I should have been more specific about my question. I am not suggesting to replace QFileSystemWatcher. I asked this question because when I was searching for a solution on Google I came across articles and forum comments with suggestions to replace/modify/update QQFileSystemWatcher in new version of QT. I thought QT may update QQFileSystemWatcher based on these suggestions or use some other subsystem like fanotify to make a new interface to monitor a directories for QT.

  • I think QFileSystemWatcher is using inotify under the hood in linux.
    Of course using Qt you have an extra overhead to due architecture and so on, but if you plan to use on a desktop or server machine then it does not make sense to use inotify for performance reason.

  • Lifetime Qt Champion

    Depends on who wrote these articles and whether there's something pending. Can you give the references ?

    On a side note, it's Qt, QT stands from Apple QuickTime

  • Hi SGaist,
    I do not remember the references but please check the below link. It is a suggestion for improving QFileSystemWatcher on Qt forum

  • Lifetime Qt Champion

    It seems that it's still a work in progress

Log in to reply