Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to detect memory leakage ?
QtWS25 Last Chance

How to detect memory leakage ?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
7 Posts 3 Posters 605 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.
  • S Offline
    S Offline
    squareroot80
    wrote on 19 Jun 2024, 11:38 last edited by
    #1

    I have found some information about logging of memory leakage detection:
    Q_LOGGING_CATEGORY(lcGcStats, "qt.qml.gc.statistics")
    Q_DECLARE_LOGGING_CATEGORY(lcGcStats)
    Q_LOGGING_CATEGORY(lcGcAllocatorStats, "qt.qml.gc.allocatorStats")
    Q_DECLARE_LOGGING_CATEGORY(lcGcAllocatorStats)
    How to use this logging category in order to detect memory leakage ?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JonB
      wrote on 19 Jun 2024, 11:54 last edited by
      #2

      Those look more like some kind of code to show memory usage.
      For "memory leakage" I would expect you to use a tool like valgrind.

      S 1 Reply Last reply 19 Jun 2024, 12:00
      3
      • J JonB
        19 Jun 2024, 11:54

        Those look more like some kind of code to show memory usage.
        For "memory leakage" I would expect you to use a tool like valgrind.

        S Offline
        S Offline
        squareroot80
        wrote on 19 Jun 2024, 12:00 last edited by squareroot80
        #3

        @JonB said in How to detect memory leakage ?:

        Those look more like some kind of code to show memory usage.
        For "memory leakage" I would expect you to use a tool like valgrind.

        Valgrind gives false positive detection even on empty qml application. Valgrind is not comfortable to detect rare leakage. I prefer logging instead of profiling.

        J 1 Reply Last reply 19 Jun 2024, 12:07
        0
        • S squareroot80
          19 Jun 2024, 12:00

          @JonB said in How to detect memory leakage ?:

          Those look more like some kind of code to show memory usage.
          For "memory leakage" I would expect you to use a tool like valgrind.

          Valgrind gives false positive detection even on empty qml application. Valgrind is not comfortable to detect rare leakage. I prefer logging instead of profiling.

          J Offline
          J Offline
          JoeCFD
          wrote on 19 Jun 2024, 12:07 last edited by JoeCFD
          #4

          @squareroot80 Asan is another one for memory leak detection. But valgrind is good enough. Not all output from valgrind is correct. But if there is a leak, valgrind is able to show it. I do not think logging is made for this.

          S 1 Reply Last reply 19 Jun 2024, 12:16
          0
          • J JoeCFD
            19 Jun 2024, 12:07

            @squareroot80 Asan is another one for memory leak detection. But valgrind is good enough. Not all output from valgrind is correct. But if there is a leak, valgrind is able to show it. I do not think logging is made for this.

            S Offline
            S Offline
            squareroot80
            wrote on 19 Jun 2024, 12:16 last edited by squareroot80
            #5

            @JoeCFD said in How to detect memory leakage ?:

            @squareroot80 Asan is another one for memory leak detection. But valgrind is good enough. Not all output from valgrind is correct. But if there is a leak, valgrind is able to show it. I do not think logging is made for this.

            What's purpose of this elements in Qt ?

            Q_LOGGING_CATEGORY(lcGcStats, "qt.qml.gc.statistics")
            Q_DECLARE_LOGGING_CATEGORY(lcGcStats)
            Q_LOGGING_CATEGORY(lcGcAllocatorStats, "qt.qml.gc.allocatorStats")
            Q_DECLARE_LOGGING_CATEGORY(lcGcAllocatorStats)
            
            J 1 Reply Last reply 19 Jun 2024, 13:40
            1
            • S Offline
              S Offline
              squareroot80
              wrote on 19 Jun 2024, 12:29 last edited by
              #6

              I took information from https://doc.qt.io/qt-6/qtqml-javascript-memory.html

              1 Reply Last reply
              0
              • S squareroot80
                19 Jun 2024, 12:16

                @JoeCFD said in How to detect memory leakage ?:

                @squareroot80 Asan is another one for memory leak detection. But valgrind is good enough. Not all output from valgrind is correct. But if there is a leak, valgrind is able to show it. I do not think logging is made for this.

                What's purpose of this elements in Qt ?

                Q_LOGGING_CATEGORY(lcGcStats, "qt.qml.gc.statistics")
                Q_DECLARE_LOGGING_CATEGORY(lcGcStats)
                Q_LOGGING_CATEGORY(lcGcAllocatorStats, "qt.qml.gc.allocatorStats")
                Q_DECLARE_LOGGING_CATEGORY(lcGcAllocatorStats)
                
                J Offline
                J Offline
                JoeCFD
                wrote on 19 Jun 2024, 13:40 last edited by JoeCFD
                #7

                @squareroot80 said in How to detect memory leakage ?:

                qt.qml.gc.statistics

                From the link:
                Note: There are memory profiling tools that do not understand this mechanism and over-report JavaScript memory usage.

                You could be right. This is QML specific and something new for me. Thanks for your post.

                1 Reply Last reply
                0

                5/7

                19 Jun 2024, 12:16

                • Login

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