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. Memory leak in using setupUi() function of Ui object
Forum Updated to NodeBB v4.3 + New Features

Memory leak in using setupUi() function of Ui object

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
4 Posts 3 Posters 610 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.
  • N Offline
    N Offline
    nagaraj_r
    wrote on last edited by
    #1

    Valgrind tool detects memory leak issue for Qt Ui object, could anyone suggest how to avoid this memory leak issue.

    Below is the code snippet for the issue location

    e69afd74-4dd9-4398-9ef2-3f03a9ec9ded-image.png

    Valgrind output memory leak issue summary for this function

    2e9f9fce-d393-4ff7-bbcc-3dfcfba0cdfc-image.png

    Your response to this issue is really appreciated.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Update your Qt to newer version.

      And in general don't worry, valgrind tends to report false positives when it comes to Qt libs.

      (Z(:^

      N 1 Reply Last reply
      3
      • sierdzioS sierdzio

        Update your Qt to newer version.

        And in general don't worry, valgrind tends to report false positives when it comes to Qt libs.

        N Offline
        N Offline
        nagaraj_r
        wrote on last edited by
        #3

        @sierdzio thanks for your response. i'll try upgrade to a latest version of Qt.

        1 Reply Last reply
        0
        • O Offline
          O Offline
          okriehn
          wrote on last edited by okriehn
          #4

          @nagaraj_r since the ui object is created on the heap (using new) and has no parent, it has to be deleted manually. You should add delete ui; to the destructor of the halconform class. Or - better - make use of the smart pointers, like std::unique_ptr. This is independent of the used Qt version.

          valgrind reports the memory leak correctly.

          See also: https://doc.qt.io/qt-5/designer-using-a-ui-file.html#using-a-pointer-member-variable

          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