I have a class that is inherited from QThread (lets called it ClassA) that is running in a for loop like following:
for(int i=0;i<somenumber;i++)
{
ClassA* classa = new ClassA();
classa->execute(); // just a normal direct function call
classa->exit();
classa->deleteLater();
}
The problem is that the classa contains a lot of memory, and it does not seem being destroyed while the loop is still running. So the program will crash soon after the memory has built up (like memory leak). I tried to use "delete classa" as well which of course will crash the program.
Anybody know how to properly run and delete such class in a loop so it won't be occupying memory constantly.
The for loop also sits in another thread. So there is a thread hierarchy where event loop might be key in calling deleteLater()? The code is a bit too complex to write up, but the quickest answer I want might be how to delete the Qthread object properly in a threading environment (i.e. using eventloop properly) so there is no memory leak (or more like memory building up as the Qthread object is not deleted)