Frage

I’m building an application which constantly creates and deletes QWebView objects. After some time, the memory consumption is growing significantly.

I build the minimal example, which demonstrates the problem.

QList<QWebView *>views;


for(int i = 0;i<500;i++)
{
    QWebView *view = new QWebView();
    view->setHtml("Test");
    views.append(view);
}

foreach(QWebView *view,views)
{
    delete view;
}
views.clear();

If I run this function in a loop, memory allocated by programm gets evenly growing. If I replace QWebView with QPlainTextEdit or other widget – the problem disappears. I also tried functions like clearMemoryCaches, setObjectCacheCapacities, deleting pages, and it still didn't work.

Is there a correct way to deallocate resources in QWebView?

I use Qt5.1 built with MinGW on Windows 7 x64.

War es hilfreich?

Lösung

The Qt WebKit is known to have many memory leaks, even though those "memory leaks" are only warnings in some cases. You can read more about it here : Qt Bug 40373, and also see the other bug reports mentioning those leaks.

However, Qt5.6 is out now (and was obviously not at the time of your question). Now, it is better to use QWebEngineView, it seems that there's no more memory leaks with this one.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top