Planned maintenance has been done but it did not solve the problem. So work will continue on this and a new time for trying updates will be announced asap.
Why qThreadpool do not clear its queue
Ehsun last edited by Ehsun
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?
@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.
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
Ehsun last edited by
@SGaist I have checked the code with destructor enabled but the memory leak still exist.
@Ehsun what destructor exactly?
You allocate memory in
Mainas well as in
Implementationwithout freeing it later/on program exit.
Header fileis free of leakage.
Ehsun last edited by
@J-Hilk you can uncomment the comented part in the destructor of myRunnable class or uncomment the for loop in run() method but after that nothing will change and no memory will free at the end
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 ?
JonB last edited by JonB
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.