[SOLVED]Memory usage increase ~20MB after each page loaded in WebView



  • Hi

    I'm using a QDeclarativeView to create a window and load webpage into it.
    After each new load memory usage increases by average 20MB. It can go up to as high as 1GB.

    How i can make sure that after new webpages are loaded the memory from previous ones is released?

    Below is minimal example:
    mainwindow.cpp
    @#include "mainwindow.h"
    #include "ui_mainwindow.h"

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    openWindow();
    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    void MainWindow::openWindow(){

            QDeclarativeView *decView=new QDeclarativeView();
            decView->setSource(QUrl("qrc:/inc/qml.qml"));
            decView->setAttribute(Qt::WA_DeleteOnClose,true);
    
         decView->show();
    

    }
    @

    qml.qml

    @import QtQuick 1.1
    import QtWebKit 1.1

    WebView {

        width:600
        height:700
        settings.javascriptEnabled: true
        settings.javascriptCanOpenWindows: true
        settings.developerExtrasEnabled : true
        settings.autoLoadImages: false
        id: webView
        objectName: "myWebView"
    
        url:"http://www.yahoo.com"
    
    
        onLoadFinished: {alert('new');webView.evaluateJavaScript("window.setTimeout('[removed].reload()',5000);");} //[removed] is window location
        onAlert: console.log(message);
    

    }
    @



  • Can someone reproduce this leak?



  • The leak is caused by
    @settings.autoLoadImages: false@

    setting it to true makes qml work fine


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.