Why qThreadpool do not clear its queue
-
I have wrote the following code by using qthreadpool. The problem is that qt does not free the memory after finishing the application. My codes are attached bellow (noting change even I uncomment the commented parts). Could you please help me?
Main
Header file
Implementation -
@Ehsun Why do you allocate myThread on the heap? Allocate it on the stack. You also should delete all myRunnable instances you created when they are not needed anymore.
P.S.: it is easier to post the source code directly here instead of photograph your display and post links to the pictures. -
-
Hi,
To add to my fellow, QThreadPool deletes the runners by default however, with your disabled destructor, all the int arrays you allocated won't get cleaned. Either use a two dimensional vector or properly clean your
myList
content. -
Just one thing, when an application quits, the memory it used is freed. What the OS does with this newly freed memory is by no mean related to Qt and varies from one platform to another.
So what exactly are you observing and how ?
-
@SGaist
Well under Windoze & Linux all memory is certainly freed on executable exit, so for Qt I can only imagine MacOS could work differently. So as you say the OP needs to explain what behaviour he is observing, and that the Qt app really has terminated. -
Like I already wrote, it has nothing to do with Qt. Qt is a C++ framework, it doesn't do anything special with respect to memory management.
So yes, since the OP wrote that the memory was not freed after the application ended then he needs to elaborate on that.