Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt Creator Valgrind Memcheck tooooo slow
Forum Updated to NodeBB v4.3 + New Features

Qt Creator Valgrind Memcheck tooooo slow

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
10 Posts 4 Posters 2.0k Views 1 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.
  • M Offline
    M Offline
    MHermann
    wrote on last edited by MHermann
    #1

    Hi,
    When I am using Valgrind Memcheck in Qt Creator the application starts but is tooooo slow.
    Is there a possibility to speed it up?
    This is the command that it used in Qt Creator to start Valgrind Memcheck.
    How can I adjust this command? Maybe it is possible to optimize the execution here?

    valgrind --child-silent-after-fork=yes --xml-socket=192.168.0.142:46155 --log-socket=192.168.0.142:46075 --xml=yes --smc-check=stack --tool=memcheck --gen-suppressions=all --track-origins=yes --leak-check=summary --num-callers=30 --vgdb=yes --vgdb-error=0 /usr/lib/path/app
    

    Kind regards

    sierdzioS P 2 Replies Last reply
    0
    • M MHermann

      Hi,
      When I am using Valgrind Memcheck in Qt Creator the application starts but is tooooo slow.
      Is there a possibility to speed it up?
      This is the command that it used in Qt Creator to start Valgrind Memcheck.
      How can I adjust this command? Maybe it is possible to optimize the execution here?

      valgrind --child-silent-after-fork=yes --xml-socket=192.168.0.142:46155 --log-socket=192.168.0.142:46075 --xml=yes --smc-check=stack --tool=memcheck --gen-suppressions=all --track-origins=yes --leak-check=summary --num-callers=30 --vgdb=yes --vgdb-error=0 /usr/lib/path/app
      

      Kind regards

      sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @MHermann said in Qt Creator Valgrind Memcheck tooooo slow:

      Is there a possibility to speed it up?

      Yes, stop using valgrind and use address sanitizer instead. It's built into all modern GCC and clang versions. It's faster and often more accurate than valgrind.

      If you're using qmake, you can add this to your .pro:

      asan {
          message("Address sanitizer: enabled. Use only in debug builds")
          CONFIG *= sanitizer sanitize_address
          QMAKE_CXXFLAGS *= "-fsanitize=address -fno-omit-frame-pointer"
          QMAKE_CFLAGS *= "-fsanitize=address -fno-omit-frame-pointer"
          QMAKE_LFLAGS *= "-fsanitize=address"
      }
      

      Then call qmake with CONFIG+=asan and rebuild your project. When you run it, asan will work and start printing all memory issues to the console.

      (Z(:^

      M P 2 Replies Last reply
      3
      • sierdzioS sierdzio

        @MHermann said in Qt Creator Valgrind Memcheck tooooo slow:

        Is there a possibility to speed it up?

        Yes, stop using valgrind and use address sanitizer instead. It's built into all modern GCC and clang versions. It's faster and often more accurate than valgrind.

        If you're using qmake, you can add this to your .pro:

        asan {
            message("Address sanitizer: enabled. Use only in debug builds")
            CONFIG *= sanitizer sanitize_address
            QMAKE_CXXFLAGS *= "-fsanitize=address -fno-omit-frame-pointer"
            QMAKE_CFLAGS *= "-fsanitize=address -fno-omit-frame-pointer"
            QMAKE_LFLAGS *= "-fsanitize=address"
        }
        

        Then call qmake with CONFIG+=asan and rebuild your project. When you run it, asan will work and start printing all memory issues to the console.

        M Offline
        M Offline
        MHermann
        wrote on last edited by MHermann
        #3

        @sierdzio:

        Okay. I tried to use address sanitizer.
        But now I get the following error message:

        ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
        
        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Hm, never seen that message :-(

          Have you used this in all of your .pro files, including the one producing the executable?

          (Z(:^

          M 1 Reply Last reply
          0
          • sierdzioS sierdzio

            Hm, never seen that message :-(

            Have you used this in all of your .pro files, including the one producing the executable?

            M Offline
            M Offline
            MHermann
            wrote on last edited by
            #5

            @sierdzio:
            I only have one .pro file.

            I had to add this environment variable: LD_PRELOAD = /usr/lib/arm-linux-gnueabihf/libasan.so.5
            Now it is working.

            P 1 Reply Last reply
            2
            • JoeCFDJ Offline
              JoeCFDJ Offline
              JoeCFD
              wrote on last edited by JoeCFD
              #6

              valgrind --help to list selections and run it from command line. It is not that slow as inside qt-creator.
              for example:
              valgrind --leak-check=full --leak-resolution=high your app

              also build your app or run your app with asan from command line. It may be faster. I use qt creator only for editing and debugging.

              1 Reply Last reply
              0
              • sierdzioS sierdzio

                @MHermann said in Qt Creator Valgrind Memcheck tooooo slow:

                Is there a possibility to speed it up?

                Yes, stop using valgrind and use address sanitizer instead. It's built into all modern GCC and clang versions. It's faster and often more accurate than valgrind.

                If you're using qmake, you can add this to your .pro:

                asan {
                    message("Address sanitizer: enabled. Use only in debug builds")
                    CONFIG *= sanitizer sanitize_address
                    QMAKE_CXXFLAGS *= "-fsanitize=address -fno-omit-frame-pointer"
                    QMAKE_CFLAGS *= "-fsanitize=address -fno-omit-frame-pointer"
                    QMAKE_LFLAGS *= "-fsanitize=address"
                }
                

                Then call qmake with CONFIG+=asan and rebuild your project. When you run it, asan will work and start printing all memory issues to the console.

                P Offline
                P Offline
                paulf
                wrote on last edited by
                #7

                @sierdzio I think that you meant "sometimes more accurate".

                ASan will detect stack variable bounds errors.

                It won't detect any issues in libc or libstdc++/libc++ unless you have a sanitizer build of those libraries.

                ASan is also only byte accurate. That means that if you use bitfields and you have a byte with a mixture of uninitialized and initialized bits then it will likely not detect an error.

                1 Reply Last reply
                0
                • M MHermann

                  Hi,
                  When I am using Valgrind Memcheck in Qt Creator the application starts but is tooooo slow.
                  Is there a possibility to speed it up?
                  This is the command that it used in Qt Creator to start Valgrind Memcheck.
                  How can I adjust this command? Maybe it is possible to optimize the execution here?

                  valgrind --child-silent-after-fork=yes --xml-socket=192.168.0.142:46155 --log-socket=192.168.0.142:46075 --xml=yes --smc-check=stack --tool=memcheck --gen-suppressions=all --track-origins=yes --leak-check=summary --num-callers=30 --vgdb=yes --vgdb-error=0 /usr/lib/path/app
                  

                  Kind regards

                  P Offline
                  P Offline
                  paulf
                  wrote on last edited by
                  #8

                  @MHermann Some comments about the options used.

                  --tool=memcheck this is the default so you don't need it (harmless though).

                  --track-origins=yes this is likely to cause a substantial slowdown. I recommend not turning this on until after an error has been detected.

                  --num-callers=30 do you really need to record callstacks to a depth of 30?

                  M 1 Reply Last reply
                  0
                  • M MHermann

                    @sierdzio:
                    I only have one .pro file.

                    I had to add this environment variable: LD_PRELOAD = /usr/lib/arm-linux-gnueabihf/libasan.so.5
                    Now it is working.

                    P Offline
                    P Offline
                    paulf
                    wrote on last edited by
                    #9

                    @MHermann You aren't trying to use both Valgrind and ASan are you? They aren't compatible.

                    1 Reply Last reply
                    0
                    • P paulf

                      @MHermann Some comments about the options used.

                      --tool=memcheck this is the default so you don't need it (harmless though).

                      --track-origins=yes this is likely to cause a substantial slowdown. I recommend not turning this on until after an error has been detected.

                      --num-callers=30 do you really need to record callstacks to a depth of 30?

                      M Offline
                      M Offline
                      MHermann
                      wrote on last edited by
                      #10

                      @paulf:

                      Thanks for the comments about the options.

                      I did not try to use both together. First I tried Valgrind, then I changed to ASan.

                      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