PDA

View Full Version : qthread memory problem, please help (ignore this, solved)



zl2k
26th September 2008, 22:33
My bad, pls ignore the following message. I found it's the std container that does not release memory as I expected, not the qt to blame for. Sorry I can't delete the original post.
==============================

hi, there
I am doing image processing and using qt for the GUI with qthread for the 4cup machine. Basically in each thread I'll do calculation on different images with no info exchange among threads. The work is queued in the qlist and 4 threads are released at the beginning. Upon receiving the signal of a thread is finished, I'll delete that job and release a new one. Overall, there are 4 threads running until all the jobs are done. Let me call my part as MyWork and the job is started by run()


void QtMyWorkAdapter::run()
{
MyWork mywork(dir_of_image.toStdString());
}

class QtMyWorkAdapter : public QThread{/*not interesting...*/}


The program seems has memory leakage somewhere related to qt, the occupied memory is constantly growing until the program crashes after 20 jobs or so. The reason I suspect qthread other than MyWork is that I don't have trouble in memory when I run MyWork directly in batch in the console window for thousands of jobs. But as I said, The program crashed with qt for only 20 jobs or so.

It seems that after run() is finished, the ~MyWork() is called automatically (which is good). Then all the memory alloc in MyWork should be released (and I do observe the recursive call of distructions for classes used by MyWork).

I appreciate if someone can point out where to nail down the problem. The valgrind gives message about qt but people said those should be suppressed.

zl2k