Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-88063

Memory leak in QNetworkAccessManager from QMetaObjectPrivate::connect

    XMLWordPrintable

Details

    • 0807f16eb407eaf8a5b34b67602d0a97778d945d 1c6d6cbb62c5e93cbcad2d740c3b0ed01095618c

    Description

      When running the attached test code, there appears to be a memory leak in QNetworkAccessManager, as the longer the program runs, the greater the memory usage (eventually running into std::bad_alloc OOM exceptions if left long enough on a machine with no swap file or a 32-bit address space). Two 88-byte QObjectPrivate::Connection structures are created per GET request that are not freed until the QNetworkAccessManager itself is destructed. This is causing issues in a long-running service that makes many thousands of HTTP requests over the course of days, slowly eating away at the machine's available RAM, eventually crashing as it exhausts its heap address space (in a 32-bit setting).

      (In this test reproduction, localhost:8000 is simply running an HTTP server that serves a small static file in response.)

      The relevant stack traces from valgrind that show the memory leak are also attached. (Deleting the global QNetworkAccessManager object causes these objects to be freed.)

      Attachments

        1. leaktest.cpp
          1 kB
          Kestrel W-K
        2. valgrind.log
          4 kB
          Kestrel W-K

        Issue Links

          For Gerrit Dashboard: QTBUG-88063
          # Subject Branch Project Status CR V

          Activity

            People

              manordheim MÃ¥rten Nordheim
              ethereal Kestrel W-K
              Maurice Kalinowski Maurice Kalinowski
              Alex Blasche Alex Blasche
              Votes:
              2 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes