-
How to delete QMap ?
I have a container like QMap<float, QList<QPair<float,float> *> *> *data, but I can't delete it.
How to solve this problem?
My code :
{
QMapIterator<float, QList<QPair<float,float> *> *> iterator(*data);
while(iterator.hasNext()) {
iterator.next();
QList<QPair<float,float> *> *timeValues = iterator.value();
qDeleteAll(*timeValues);
timeValues->clear();
}
qDeleteAll(*data);
data->clear();
delete data;
data = NULL;
}
but it doesn't work, at least the memory is not given back to OS immediately.
-
Re: How to delete QMap ?
The memory will not be deallocated from the process immediately, that's a normal thing in modern operating systems.
And why are you keeping a pointer to a QList in the map instead of QList itself?
-
Re: How to delete QMap ?
Thanks , if I change it to QMap<float, QList<QPair<float,float>>> *data,
Would it be deallocated immediately?
-
Re: How to delete QMap ?
No, if you change it to 20 year old operating system then maybe it will. But if you remove the pointer from the data structure you will not have to manually delete each value in the map.