Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Memory leak bug with Qt Quick (QT 6.2.1)



  • Hi,

    I made a simple Qt Widgets Application in Visual Studio, where I only imported the default Cube QtQuick application created with Qt Design Studio.

    I made a QGridlayout in the QMainWindow and set it so it follows the size of the central widget when manually resizing the window with the mouse.

    I set the QQuickView in the QGridLayout, and when I resize the window, the RAM usage goes up a little bit, but never comes down. If I continuously resize the window, the RAM ramps up indefinitely and never comes down.

    Here is the snippet code from the main window, associated with the default QtQuick project from QT Design Studio :

    QT 6.2.1

    test3DcppVS::test3DcppVS(QWidget *parent)
        : QMainWindow(parent)
    {
        QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL);
        QQuickWidget* quickWidget = new QQuickWidget();
        quickWidget->engine()->addImportPath("qrc:/test3DcppVS/qml/imports");
        quickWidget->setSource(QUrl("qrc:/test3DcppVS/qml/content/Screen01.ui.qml"));
        quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
        ui.setupUi(this);
    
        ui.gridLayout->addWidget(quickWidget);
    }
    

    This Memory leak does not happen if the QQuickWidget is not resized with the window.
    Am I missing something? Am I suppose to manually garbage collect anything?



  • @MStackoverflo said in Memory leak bug with Qt Quick (QT 6.2.1):

    QQuickWidget* quickWidget = new QQuickWidget();

    QQuickWidget* quickWidget = new QQuickWidget();
    how is quickWidget cleared? it does not have a parent. ui.gridLayout can not clear it.



  • I've replaced it with

    QQuickWidget* quickWidget = new QQuickWidget(this);
    

    I still get the same behavior.





  • Thanks for the tip on Stackoverflow, I can see that QT6Guid is Allocating that memory but never releases it. Also there is Unresolved Allocation which I don't know what it is.

    The test was :

    • Set the window to minimum size
    • Take Memory Snapshot
    • Resize the window by dragging the mouse multiple time
    • Take a Memory Snapshot
    • Repeat One more time

    Anybody have a clue on what's happening?

    Unresolved Allocation
    Qt6Guid.dll!QGles2GraphicsPipeline

    7c2604ad-30bc-4895-9081-13effed9726a-image.png


Log in to reply