Unsolved Memory leak in using setupUi() function of Ui object
-
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
Valgrind output memory leak issue summary for this function
Your response to this issue is really appreciated.
-
Update your Qt to newer version.
And in general don't worry,
valgrind
tends to report false positives when it comes to Qt libs. -
@sierdzio thanks for your response. i'll try upgrade to a latest version of Qt.
-
@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