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

Memory is not released after QWebEngineView was deleted



  • I was writing a thin client for Google Tasks with using QWebEngine instead of authorizing with browser when I noticed that my app uses the same amount of memory when QWebEngineView was deleted.
    How does QWebEngine manage memory? Running this short example (created on "Qt app with widgets template") shows that 15 megabytes were completely lost (Ubuntu 20.04 LTS, Wayland session, Qt 5.12 from apt)

    #include "mainwindow.h"
    
    #include <QApplication>
    #include <QDebug>
    
    #include <QtWebEngineWidgets/QtWebEngineWidgets>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
    
        auto view = new QWebEngineView{};
        view->setUrl(QUrl{"www.google.com"});
        qDebug() << view;
        w.setCentralWidget(view);
        w.connect(view, &QWebEngineView::loadFinished, [&w](){
            w.show();
            delete w.takeCentralWidget();
        });
        w.connect(view, &QObject::destroyed, [](void * ptr){
            qDebug() << ptr;
        });
        return a.exec();
    }
    

    You can see on screenshots below that this short example uses 20 Mb on launch and 35 Mb when memory considered release. The app I try to implement uses the same 20 Mb before view was allocated and 45 Mb after it was deleted.
    Снимок экрана от 2020-11-23 23-41-29.png
    Снимок экрана от 2020-11-23 23-41-42.png
    I know that malloc might not release the memory just because I wrote delete something but we are talking 15 Mb at least which should definitely be released.
    How can I reduce memory usage after deletion of last (and the only) QWebEngineView?



  • @Dramcryx
    Did you try valgrind for an alternative view/clues?



  • @JonB the result is ambiguous I would say: https://pastebin.com/RC8NjkCJ
    I can't see the full track because it creates a zygote process for WebEngine and it's generally full of errors. :((


Log in to reply