[webkit-help] How to clear memory held by QtWebkit?
annulen at yandex.ru
Tue Dec 13 08:52:52 PST 2016
13.12.2016, 19:35, "Bono Damodi" <probablynotthebestone at gmail.com>:
> is there a way to deinitialise QtWebkit in runtime completely? For example for this code:
> #include <QApplication>
> #include <QGraphicsWebView>
> #include <QUrl>
> #include <QTimer>
> QGraphicsWebView* graphicsWebView;
> class Deleter : public QObject
> public slots:
> void deleteWebView()
> delete graphicsWebView;
> int main(int argc, char *argv)
> QApplication app(argc, argv);
> graphicsWebView = new QGraphicsWebView;
> Deleter d;
> QTimer::singleShot(10000, &d, SLOT(deleteWebView()));
> return app.exec();
> #include "main.moc"
> After deleting graphicsWebView object there is still used about 2mb of physical memory (more than 6 mb of virtual memory) by Webkit's OSAllocator (I tracked mmap's calls by OSAllocator and then correlated with /proc/pid/smaps). Much of the memory seems to be requested by JSC::JIT::compile function.
> Is there some way to completely clean QtWebkit after it was initialised?
To clear code compiled by JIT it should be enough to QWebSettings::clearMemoryCaches()
However, note that it's not ever possible to clear 100% of memory allocated by WebKit (any port), because a lot of data structures are by design NeverDestroyed (look for DEFINE_STATIC_LOCAL in your QtWebKit version).
> This is Qt 4.8
Please consider upgrading to Qt 5. Qt 4.8 have reached EOL, and all compatible QtWebKit versions are horribly out of date.
> Best regards
> webkit-help mailing list
> webkit-help at lists.webkit.org
More information about the webkit-help