Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to deactivate (or fix) false positive memory leak with CRT (windows, msvc)
Forum Updated to NodeBB v4.3 + New Features

How to deactivate (or fix) false positive memory leak with CRT (windows, msvc)

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 385 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • CharbyC Offline
    CharbyC Offline
    Charby
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      ssbssa
      wrote on last edited by
      #2

      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).
      If Control 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.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved