[Qt-interest] QtWebKit and memory usage

Joel A. Iturra P. tortuguero at gmail.com
Tue Feb 17 21:13:49 CET 2009


Hi all,

(I'm new on this mailing list, please tell me if I make a mistake)

I need visit many web pages for monitoring purposes, then I use
QWebView and other QtWebKit classes.

Yesterday I discover bad memory usage on my application. After
every new web page loaded (with setUrl()), the memory usage increases.

Looking for problem on my application, I made one simple program, one
QWebView setting
without history and cache. After every loadFinished() signal, I load
again the same
page.

(Note: I use qt 4.5 rc1 on debian linux)

But the same problem occurs. After the first load, memory on my
desktop for this process was 1.8%,
but after every new load, this percent increase (0.1% or 0.2% on every reload).

I don't know if exists some method that free memory or is a bug, maybe
I do something wrong.

Thanks

-- 
Joel A. Iturra
Santiago - Chile


This is mainwindow.cpp for testing



#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindowClass)
{
    ui->setupUi(this);
    connect(ui->webView, SIGNAL(loadFinished(bool)), this, SLOT(load()));

    QWebPage *page = ui->webView->page();
    QWebHistory *history = page->history();
    history->setMaximumItemCount(0);

    QWebSettings *settings = ui->webView->settings();
    settings->setMaximumPagesInCache(0);
    settings->setObjectCacheCapacities(0, 0, 0);
    settings->setIconDatabasePath("");

    settings->setAttribute(QWebSettings::JavascriptEnabled, true);
    settings->setAttribute(QWebSettings::PluginsEnabled, true);
    settings->setAttribute(QWebSettings::AutoLoadImages, true);
    settings->setAttribute(QWebSettings::JavaEnabled, false);
    settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
    settings->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);
    settings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, false);

    ui->webView->setUrl(QUrl("http://<url>"));
}

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

void MainWindow::load()
{
    ui->webView->setUrl(QUrl("http://<url>"));
}



More information about the Qt-interest-old mailing list