Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. If I do not connect a slot to QNetworkAccessManager::finished() will QNetworkReply objects leak?
Qt 6.12 LTS is out! See what's new in the release blog

If I do not connect a slot to QNetworkAccessManager::finished() will QNetworkReply objects leak?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.4k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    I assume, the QNR object created by the QNAM are created with the QNAM as their parents, so they will not "leak", they will indeed being deleted when their parent QNAM is deleted. However, if noone ever connects a finished slot to the signal, I assume the QNR are still created and kept around for all the lifetime of their parent QNAM. This will increase memory footprint over time. Is my assumption correct?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tomma
      wrote on last edited by
      #2

      I am pretty sure their deletion is your responsibility. You can connect their finished signal to deleteLater slots to make sure they are not leaked.

      1 Reply Last reply
      0
      • JKSHJ Online
        JKSHJ Online
        JKSH
        Moderators
        wrote on last edited by
        #3

        [quote author="philk" date="1376174647"]I assume, the QNR object created by the QNAM are created with the QNAM as their parents[/quote]No, they're not. It's in the "documentation":http://qt-project.org/doc/qt-5.1/qtnetwork/qnetworkaccessmanager.html:
        [quote]After the request has finished, it is the responsibility of the user to delete the QNetworkReply object at an appropriate time. Do not directly delete it inside the slot connected to finished(). You can use the deleteLater() function.[/quote]

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        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
        • Unsolved