Qt memory, delete operator [SOLVED]
-
currently i think there are no memory leaks in my code.
Th program is using qgraphicsscene and a ton of qgraphicsitems (i tried a couple of qdebugs in the destructors of the graphics items and everything seems to go away when i decide to)however in the windows process manager the memory of the application does NOT seem to ever go down..
even when i just create man items and then delete them all, again in the process explorer the used memory does not seem to go down!
-
That could be because the "freed" memory is just put back into a memory pool, ready for allocation. Getting memory from the operating system can be costly, so many implementations don't give that memory back to the operating system instantly.
It's hard to say if that's what's actually going on, but it's a possible explanation. -
so any solution?
"http://doc.qt.nokia.com/4.7-snapshot/qt-performance.html#alternative-memory-allocation":http://doc.qt.nokia.com/4.7-snapshot/qt-performance.html#alternative-memory-allocation
would overloading new and using malloc as stated in the article help?
-
As already described by Terence it could be the OS management respectively some internal logic avoiding too many costly allocation and deallocations. In addition the process manager may have also some delay in showing the effects of deallocating memory.
Certainly you can overwrite the new operator and do all yourself, but the question is, if it is helping at the end.
If you are not sure that this might be memory leak you can allocate and free for instance in a loop and see, if the memory will be reused. If you have a memory leak, the memory consumption will increase every time until no memory is left.
-
thank you for your answers,
will try a loop and see...