Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. Memory is not released after QWebEngineView was deleted
Qt 6.11 is out! See what's new in the release blog

Memory is not released after QWebEngineView was deleted

Scheduled Pinned Locked Moved Unsolved QtWebEngine
3 Posts 2 Posters 899 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.
  • D Offline
    D Offline
    Dramcryx
    wrote on last edited by
    #1

    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?

    JonBJ 1 Reply Last reply
    0
    • D Dramcryx

      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?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

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

      D 1 Reply Last reply
      0
      • JonBJ JonB

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

        D Offline
        D Offline
        Dramcryx
        wrote on last edited by
        #3

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

        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