QML FileDialog memory leak

  • Valgrind detects a memory leak in FileDialog. Is it a problem or just incorrect usage of dialog?


    #include <QApplication>
    #include <QQmlApplicationEngine>
    int main(int argc, char *argv[])
        QApplication app(argc, argv);
        QQmlApplicationEngine engine;
        return app.exec();


    import QtQuick 2.4
    import QtQuick.Controls 1.3
    import QtQuick.Window 2.2
    import QtQuick.Dialogs 1.2
    ApplicationWindow {
        width: 640
        height: 480
        visible: true
        Button {
            id: button1
            text: qsTr("Press Me 1")
            onClicked: saveFileDialog.visible = true
        FileDialog {
            id: saveFileDialog
            title: qsTr("Please choose a file")
            selectExisting: false
            selectMultiple: false
            nameFilters: [ qsTr("XML files (*.xml)"), qsTr("All files (*)") ]
            onAccepted: {
            onRejected: {

    Valgrind output:

    136 (16 direct, 120 indirect) bytes in 1 blocks are definitely lost in loss record 10,536 of 11,981
      в main в /home/blex/ml/main.cpp:8
      1: operator new(unsigned long) в /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so
      2: QQmlFileSelectorPrivate::QQmlFileSelectorPrivate() в /home/blex/Qt/5.4/gcc_64/lib/libQt5Qml.so.5.4.2
      3: QQmlFileSelector::QQmlFileSelector(QQmlEngine*, QObject*) в /home/blex/Qt/5.4/gcc_64/lib/libQt5Qml.so.5.4.2
      4: QQmlApplicationEnginePrivate::init() в /home/blex/Qt/5.4/gcc_64/lib/libQt5Qml.so.5.4.2
      5: main в /home/blex/ml/main.cpp:8


  • Having the same issue even with simpler HelloWorld application.


    import QtQuick 2.3
    import QtQuick.Window 2.2
    Window {
        visible: true
        MouseArea {
            anchors.fill: parent
            onClicked: {
        Text {
            text: qsTr("Hello World")
            anchors.centerIn: parent

    Valgrind reports exact the same error as you post.

  • Hi! Looks like this isn't in the bug tracker yet. Please report it to bugreports.qt.io.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.