[SOLVED] Memory operations in QList..
In the QList<T>, if "append" or "insert" is called, internally "new" is performed to make room for new element.
My question is that will "delete" be performed when i call any of the "remove" function.??
or the memory will be deleted only upon call to destructor...
There is not always a new performed; it depends on the data type you're storing in QList. Do you have any issues with QList, or are you just curious?
Also: considder using QVector instead of QList. It is often a better choice.
I am designing a code in which I need to store data of type structure.
Writing to and reading from QList will be frequent. So in order to prevent frequent "new" and "delete", I need to know the operations behind the scene. in both cases, storing data to and removing data from QList or say in which scenarios new and delete will be performed.
Note that the internal array only ever gets bigger over the life of the list. It never shrinks. The internal array is deallocated by the destructor and by the assignment operator, when one list is assigned to another.
I found this in help page of QList. As per this, memory is de-allocated only when the destructor is called or QList is assigned to it.
I consider this as solved.
If you mark a topic as Solved, please do so by editing your opening post and prepending [Solved] to the title of the topic from there. There is an edit link on the right of each of your posts.
Yes, i have already done it.