How to deactivate (or fix) false positive memory leak with CRT (windows, msvc)
-
I am annoyed with a huge dump of memory leaks detection which I think are likely to be false positive.
In my application, we are using a lots of svg icon on QAction, like this :someaction = new QAction("label", this); someaction->setIcon(QIcon(":PATHTOSVG");
As the QAction is parented to a QObject, the QAction gets deleted by its parent.
Despite the destruction of the QAction, a very large dump of memory leaks is generated after the execution of the application.
Memory leaks tools such as Heob, Wonderleak are listing this kind of setIcon as leaks but I failed to find a workaround.Could anyone indicate a fix or a way to deactivate CRT ( I tried to add _CrtSetDbgFlag ( 0 ); at the very beginning of the main but I still have the annoying dump) ?
I am using Qt6.6.3, MSVC2019 kit.
Thanks for your help. -
If heob shows a leak after program exit, then it means the memory was not (yet) freed at the time when
ExitProcess
was called.
It is possible that some memory is freed after ExitProcess, when a DLL is unloaded, but I don't think that's usually true for Qt objects.
The-d4
parameter of heob can be used to check for leaks after all DLLs were unloaded, maybe it makes a difference in this case (but I doubt it).
IfControl leak recording
is enabled, you can control in the heob console when to start/stop recording memory allocations, and also output all current non-freed memory at any time.