QDeleteAll is running very slow for large number of objects, any recommendations !?
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)?
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.
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?
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.
thank you. I'll give it a try ..