Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]Memory usage increase ~20MB after each page loaded in WebView
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
3 Posts 1 Posters 1.8k Views 1 Watching
  • 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.
  • 1 Offline
    1 Offline
    1roo
    wrote on last edited by
    #1

    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);
    

    }
    @

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

      Can someone reproduce this leak?

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

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

        setting it to true makes qml work fine

        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