I can't use 'mappedREduced' because I did not find out how to have access to intermediate results, before the whole is finished, and I found a way to do that with 'mapped' instead, which is good!...
... but there is one feature that I really miss from the 'mappedReduced': its nice memory management! As soon as a result is delivered by the 'mapped' function and goes through the 'reduce' function, its memory is released, which keeps the total used memory at any moment very low.
With 'mapped', the memory of all results is simply accumulated (I easily end up with 500MB usage or more, while I could stay below 50MB with 'mappedReduced') and I have to delete the future's result the hard way at the end...
I call a postprocessing function when a resultReadyAt() signal is emitted, using the 'resultAt()' data, and I'd like this memory to be released afterwards, since I don't need it any more.
My result is a struct containing a QVector, and this latter contains all the heavy data. But calling 'clear()' or 'resize(0)' on that vector does not help. The data is still there (I tested!! I can read it out even after the 'clear()').
The code looks like this:
void CMyClass::resultReadyAt(int pos)
{
doPostProcess(future->resultAt(pos));
future->resultAt(pos).iVector.clear(); // does not help !!
future->resultAt(pos).iVector.resize(0); // does not help either !!
qDebug() << "Items left in the vector" << pos << ":" << future->resultAt(pos).iVector.count(); // Still indicates the same amount of data!!
//delete (&future->resultAt(pos).iVector); // does not work: causes the program to crash !!
}
void CMyClass::resultReadyAt(int pos)
{
doPostProcess(future->resultAt(pos));
future->resultAt(pos).iVector.clear(); // does not help !!
future->resultAt(pos).iVector.resize(0); // does not help either !!
qDebug() << "Items left in the vector" << pos << ":" << future->resultAt(pos).iVector.count(); // Still indicates the same amount of data!!
//delete (&future->resultAt(pos).iVector); // does not work: causes the program to crash !!
}
To copy to clipboard, switch view to plain text mode
If you know about a solution, or even just have a suggestion, feel free to let me know, I would be very grateful!
Bookmarks