Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Memory leak bug with Qt Quick (QT 6.2.1)
Forum Updated to NodeBB v4.3 + New Features

Memory leak bug with Qt Quick (QT 6.2.1)

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 2 Posters 713 Views
  • 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.
  • M Offline
    M Offline
    MStackoverflo
    wrote on last edited by MStackoverflo
    #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?

    1 Reply Last reply
    0
    • JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by
      #2

      @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.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MStackoverflo
        wrote on last edited by
        #3

        I've replaced it with

        QQuickWidget* quickWidget = new QQuickWidget(this);
        

        I still get the same behavior.

        1 Reply Last reply
        0
        • JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote on last edited by
          #4

          https://stackoverflow.com/questions/4790564/finding-memory-leaks-in-a-c-application-with-visual-studio

          1 Reply Last reply
          0
          • M Offline
            M Offline
            MStackoverflo
            wrote on last edited by MStackoverflo
            #5

            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

            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