Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-7922

QFileDialog::getExistingDirectory() memory usage problems

    XMLWordPrintable

Details

    • a4c2e95ce16b3c4f9e0c9c983fb1ce9e70b5ce5a

    Description

      When using QFileDialog::getExistingDirectory(), if you open a folder containing many sub folders(100's to 1000's) memory usage will rise significantly. Navigating to another folder with significantly fewer sub folders will lower memory usage, while returning the the folder containing many sub folders causes the memory to rise again. The problem is that when QFileDialog::getExistingDirectory() returns, the memory is still allocated. This is undesirable as this is just wasted memory that is not accessible and there is no method to release this memory.

      The problems seem to be that QFileDialog creates a second thread that contains an instance of QFileInfoGatherer that allocates data associated with the sub folders mentioned above. This information is never deallocated when QFileDialog is closed and it should be, or there should at least be a method to flush this if it is done on purpose.

      I have attached an example that demonstrates this behavior. Run the generatefiles.sh script in the test folder to generate 10,000 subfolders. Then build and run the example and notice how when you open up the test folder the Memory usage increases by 5 megabytes. After you close the dialog, this memory will still be in use. I've also attached the valgrind massif output.

      Attachments

        1. create_files.sh
          0.1 kB
        2. findfiles.7z
          3 kB
        3. massif.out.3992
          722 kB
        4. QFileDialogHeapError.zip
          90 kB
        5. watcher.sh
          0.0 kB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              tpochep Timur Pocheptsov
              janichol Andy Nichols
              Votes:
              8 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes