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. Memory leak then using QNetworkProxy
Qt 6.11 is out! See what's new in the release blog

Memory leak then using QNetworkProxy

Scheduled Pinned Locked Moved Unsolved General and Desktop
17 Posts 6 Posters 2.0k Views 2 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.
  • Christian EhrlicherC Christian Ehrlicher

    @jonb said in Memory leak then using QNetworkProxy:

    And I believe it's always safe

    No need to only believe it - it's safe and I don't see where the assumption that it should not work comes from :)
    Now to the real problem. First QNetworkAccessManager should not be created inside the loop but only once (see documentation). Then - how did you measure your memleak? I don't see anything problematic with valgrind nor heaptrack...

    D Offline
    D Offline
    denys
    wrote on last edited by denys
    #8

    @christian-ehrlicher said in Memory leak then using QNetworkProxy:

    Now to the real problem. First QNetworkAccessManager should not be created inside the loop but only once (see documentation). Then - how did you measure your memleak? I don't see anything problematic with valgrind nor heaptrack...

    really, if we create only one object of QNetworkAccessManager there is no memory leak. but documentation don't say that we can't create some instances of QNetworkAccessManager.
    In my real app I have many threads - and each create personal instance of QNetworkAccessManager. So I need as many objects QNetworkAccessManager as I have threads.
    About measuring memory leak - I just look at memory manager. Each time, after loop execution, memory used by program increasing by 1Mb.

    J.HilkJ 1 Reply Last reply
    0
    • D denys

      @christian-ehrlicher said in Memory leak then using QNetworkProxy:

      Now to the real problem. First QNetworkAccessManager should not be created inside the loop but only once (see documentation). Then - how did you measure your memleak? I don't see anything problematic with valgrind nor heaptrack...

      really, if we create only one object of QNetworkAccessManager there is no memory leak. but documentation don't say that we can't create some instances of QNetworkAccessManager.
      In my real app I have many threads - and each create personal instance of QNetworkAccessManager. So I need as many objects QNetworkAccessManager as I have threads.
      About measuring memory leak - I just look at memory manager. Each time, after loop execution, memory used by program increasing by 1Mb.

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #9

      @denys said in Memory leak then using QNetworkProxy:

      In my real app I have many threads - and each create personal instance of QNetworkAccessManager. So I need as many objects QNetworkAccessManager as I have threads.

      do you really?
      QNetworkAccessManager is asynchronous to be gin with and can handle 5(iirc) requests in parallel.


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      mrjjM D 2 Replies Last reply
      2
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #10

        @denys said in Memory leak then using QNetworkProxy:

        I just look at memory manager

        This is no indicator if there is a memory leak or not. It's not even an indication... use a correct tool.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        D 1 Reply Last reply
        2
        • J.HilkJ J.Hilk

          @denys said in Memory leak then using QNetworkProxy:

          In my real app I have many threads - and each create personal instance of QNetworkAccessManager. So I need as many objects QNetworkAccessManager as I have threads.

          do you really?
          QNetworkAccessManager is asynchronous to be gin with and can handle 5(iirc) requests in parallel.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #11

          @j-hilk
          6 i think :)
          But i totally agree that this use case might not warrants using threads.

          1 Reply Last reply
          2
          • J.HilkJ J.Hilk

            @denys said in Memory leak then using QNetworkProxy:

            In my real app I have many threads - and each create personal instance of QNetworkAccessManager. So I need as many objects QNetworkAccessManager as I have threads.

            do you really?
            QNetworkAccessManager is asynchronous to be gin with and can handle 5(iirc) requests in parallel.

            D Offline
            D Offline
            denys
            wrote on last edited by
            #12

            @j-hilk said in Memory leak then using QNetworkProxy:

            do you really?
            QNetworkAccessManager is asynchronous to be gin with and can handle 5(iirc) requests in parallel.

            QNetworkAccessManager Class
            Note: All functions in this class are reentrant.
            ...a class is said to be reentrant if its member functions can be called safely from multiple threads, as long as each thread uses a different instance of the class

            1 Reply Last reply
            0
            • Christian EhrlicherC Christian Ehrlicher

              @denys said in Memory leak then using QNetworkProxy:

              I just look at memory manager

              This is no indicator if there is a memory leak or not. It's not even an indication... use a correct tool.

              D Offline
              D Offline
              denys
              wrote on last edited by
              #13

              @christian-ehrlicher said in Memory leak then using QNetworkProxy:

              This is no indicator if there is a memory leak or not. It's not even an indication... use a correct tool.

              Check it by Heob.
              if I download from http (not https) or don't use proxy - there is 1 memory leak error - 665b for any count (>0) of loop pass
              But when i try download from https and use proxy - there is same 1 memory leak error + 8 errors for each loop pass

              results for loop with 5 passes:
              https://drive.google.com/open?id=1YEo_BdAuQDSG4ZEfRTxyMup19STf6KS8

              1 Reply Last reply
              0
              • Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by Christian Ehrlicher
                #14

                @denys said in Memory leak then using QNetworkProxy:

                8 errors for each loop pass

                I can't find this in leaks(https,proxy) anywhere... can you please create html output

                I can only see that there is a global static QGlobalNetworkProxy which is wrongly reported as leak (depending on the definition of a leak - QGlobalNetworkProxy it's only allocated once and not cleaned up on exit but that's what a Q_GLOBAL_STATIC is for.)

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                1 Reply Last reply
                2
                • D Offline
                  D Offline
                  denys
                  wrote on last edited by
                  #15
                  This post is deleted!
                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    denys
                    wrote on last edited by
                    #16

                    @christian-ehrlicher said in Memory leak then using QNetworkProxy:

                    I can't find this in leaks(https,proxy) anywhere... can you please create html output

                    https://drive.google.com/open?id=1_pBZlXd_LR5UJi5OCi-zH_VSgL-qgrgb

                    1 Reply Last reply
                    0
                    • Christian EhrlicherC Offline
                      Christian EhrlicherC Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on last edited by
                      #17

                      Even your heob output prints some small leaks which may be real leaks I can't see anything here on linux with valgrind. I even added a debug output in the QHttpNetworkReply ctor and dtor to see if it is leaking but no way.
                      Your whole testcase looks fishy - esp. the re-creation of the QNAM inside the loop will for sure not be optimal and result in a comment in the bugreport about the wrong usage. I would suggest you to rewrite the testcase (to use threads) instead this imo wrong usage.

                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                      Visit the Qt Academy at https://academy.qt.io/catalog

                      1 Reply Last reply
                      1

                      • Login

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