Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QDeleteAll is running very slow for large number of objects, any recommendations !?
Forum Updated to NodeBB v4.3 + New Features

QDeleteAll is running very slow for large number of objects, any recommendations !?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    roozbehg
    wrote on last edited by
    #1

    I've been using qDeleteAll to deallocate QList of objects and had no problem for number of object less than 1000-2000 but waiting time drastically increases after adding more and more objects to the list. is there any optimum method to deallocate the QList all at once (mass deallocation)?

    -Roozbeh

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      qDeleteAll() itself has complexity O(n), so more objects in a container more time it takes to deallocate.

      Is the time for a container deallocation growing linearly?
      If not then it is possible that the destructor of the objects in the container does some time consuming actions. You may take a look in that direction.

      If the objects in a container are not QWidget based you may try to move deallocation to another thread.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        roozbehg
        wrote on last edited by
        #3

        thanks andreyc for your quick reply.
        make sense. how can I move the deallocation to another thread? would you please explain a little bit more?

        -Roozbeh

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andreyc
          wrote on last edited by
          #4

          You create a function or an object that will call qDeleteAll() and run this function or an object in another thread when you need to delete all objects.
          There are multiple ways to run the functions or the objects in separate thread. It depends on the architecture of your app.
          Take a look on "different use cases":http://qt-project.org/doc/qt-5/threads-technologies.html#example-use-cases I guess it maybe one of the "One call" use cases.

          1 Reply Last reply
          0
          • R Offline
            R Offline
            roozbehg
            wrote on last edited by
            #5

            thank you. I'll give it a try ..

            -Roozbeh

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved