Search code examples
qtmemory-leaksqt5qwebview

How do I avoid memory leak when closing a QWebView?


I do call close() on my main window's exit event but I can see on console memory leaks; such as:

LEAK: 3 XMLHttpRequest
LEAK: 26 CachedResource
LEAK: 293 WebCoreNode

I do close the browser like this:

void MainWindow::closeEvent(QCloseEvent *e)
{
    Q_UNUSED(e);
    webControl.close();
}

webControlis of QWebPage type and MainWindow is QMainWindow.

What's the proper way to way to close the web browser control soon as close the main window is requested so that I can avoid such memory leaks?


Solution

  • I remember having answered it before, there it is: Memory leak in QWebView.

    This answer was for a previous version of Qt (5.4.2), but I found out that it still affects the recent versions: see here and here.

    Unfortunately, there is nothing you can do about it, as all these reported bugs were not solved yet in the latest version (Qt5.9.2).