In code below, does the erase() free the memory? I have code that uses that principle to delete large amounts of points after certain conditions. After iterating through and erasing bunch of points, the count() returns what I expect and if I iterate through the graph plot now, the expected points have been deleted so looks like the logic worked. ... but I see no increase in free memory, not in /proc/meminfo (freemem+buffers+cached) anyway.
void deleteTest(QCPGraph* graph)
{
QCPDataMap *dataMap;
if (!graph)
{
return;
}
if (!graph->data())
{
return;
}
dataMap = graph->data();
QMap<double, QCPData>::iterator it = dataMap->begin();
while (it != dataMap->end()) {
if (some condition) {
it = dataMap->erase(it); // this increments "it" automatically
}
else
++it;
}
}