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. [SOLVED] Do I have to care about these memory leaks ?
Forum Update on Monday, May 27th 2025

[SOLVED] Do I have to care about these memory leaks ?

Scheduled Pinned Locked Moved General and Desktop
instrumentsleaksmemorymacos x
6 Posts 3 Posters 2.3k Views
  • 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.
  • M Offline
    M Offline
    Moonlight-Angel
    wrote on last edited by Moonlight-Angel
    #1

    Hello,

    I was chasing memory leaks in my application and tried out Instruments > Leaks on OS X.
    I had some memory leaks that were coming from my application and fixed these.
    Now, my application doesn't leak anymore (according to Leaks).
    However, there are many other leaks that don't come from my application, they seem to come from QtCore, Foundation, IOKit, etc... Do I really have to care about them ?

    Here's a screenshot from the leaks and the graphic showing memory usage (with my application running for ~16mn).

    Btw, if I take a look in Activity Monitor, the memory my application is using keeps getting higher (like 2Mo in 15mn), is this really a problem or not ? Is Activity Monitor (or Task Manager under Windows for example) really accurate ?

    Thanks for your help !

    No keyboard found. Press any key to continue.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      I'm not familiar with Leaks.
      I know that sometime the tools like valgrind report memory in the libraries which are not really memory leak.

      But if you see a constant grow in the memory usage then you may have a memory leak.
      I would analyze the suspicious places and try to turn them off and see if memory usage is stable.

      For example, you have some big buffer coming from a network and then you process it and do some other things that involves a memory allocation.
      Try to discard the buffer immediately on receive and check the memory usage.
      If it is stable then go to next step in the processing pipeline.
      And continue it until you will see the memory usage increase.

      Another option to find a leak would be try to build and run your app for Linux and run it under valgrind.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        To add to @andreyc, another technique is to reduce your code up to the point where you can easily provoke the leak

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • M Offline
          M Offline
          Moonlight-Angel
          wrote on last edited by
          #4

          Thanks for your responses.

          The thing is that Activity Monitor for example seems to say that memory usage is growing slowly but at the same time, the graphic in Leaks stays flat (as you can see on the screen) and I don't know which one I can "trust".
          I don't think I'm wrong if I trust Leaks rather than Activity Monitor, but I just want to make sure I don't miss any leak hidden in false positives as @andreyc says.

          I'll give Valgrind a try as I know it may be more accurate on Linux.
          IMO if Leaks doesn't detect any leak coming from my Application name (responsible library), I should be good to go.

          No keyboard found. Press any key to continue.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Indeed, in terms of OS X libraries there's not much you can do from your code. However if you find something inside Qt's library then it's worth at least verifying on e.g. IRC #qt channel and/or the interest mailing.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • M Offline
              M Offline
              Moonlight-Angel
              wrote on last edited by
              #6

              Ok, thanks :).

              No keyboard found. Press any key to continue.

              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