Disabling the cache

A goal of mine is to decrease and limit the memory usage of WebKit. In embedded environments, memory can be even more important than performance. I was interested how can the memory consumption be lowered with the functionality already present in WebKit's code base, i.e., without too much hacking of the code.

I experimented with QtWebKit, revision 42745. In main(), I found two method calls that set up the resource cache of WebKit. These can be used to disable the cache:

QWebSettings::setObjectCacheCapacities(0, 0, 0);

The effect of this modification was measured on an x86-linux box. (First, I did the measurement on a vanilla QtWebKit, but since WebKit is leaking and shows a constantly growing memory consumption, I had to apply a patch to fix the issue. Then, I kept using this patch in all measurements.) In the measurements, I compared the maximum resident set size (maxRSS) of QtLauncher executed with caches enabled and disabled (as given above).

I measured two scenarios: in the first, I loaded 5 pages in a loop (1, 2, 3, 4, 5), while in the second, I loaded 170 pages one after the other (they were collected from Alexa by recursive webcrawling).

Scenario Cache enabled Cache disabled
5 pages, 25 times 48,284 KB 42,020 KB
170 pages, once 158,100 KB 152,352 KB

So, it seems that disabling the cache can save us ~6MB of memory.

(PS: Interestingly, when the leak-fixing patch was not applied to the code, disabling the cache had no effect on the maxRSS.)

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • No HTML tags allowed
  • Lines and paragraphs break automatically.

More information about formatting options

This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Fill in the blank