summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--content/content.c5
-rw-r--r--content/content.h1
-rw-r--r--desktop/netsurf.c11
3 files changed, 14 insertions, 3 deletions
diff --git a/content/content.c b/content/content.c
index e4431453a..63b7f7b26 100644
--- a/content/content.c
+++ b/content/content.c
@@ -873,14 +873,15 @@ void content_clean(void)
next = 0;
for (c = content_list; c; c = c->next) {
next = c;
- size += c->size + talloc_total_size(c);
+ c->talloc_size = talloc_total_size(c);
+ size += c->size + c->talloc_size;
}
for (c = next; c && (unsigned int) option_memory_cache_size < size;
c = prev) {
prev = c->prev;
if (c->user_list->next)
continue;
- size -= c->size + talloc_total_size(c);
+ size -= c->size + c->talloc_size;
content_destroy(c);
}
}
diff --git a/content/content.h b/content/content.h
index ae43b933e..a44d36782 100644
--- a/content/content.h
+++ b/content/content.h
@@ -232,6 +232,7 @@ struct content {
unsigned int size; /**< Estimated size of all data
associated with this content, except
alloced as talloc children of this. */
+ off_t talloc_size; /**< Used by content_clean() */
char *title; /**< Title for browser window. */
unsigned int active; /**< Number of child fetches or
conversions currently in progress. */
diff --git a/desktop/netsurf.c b/desktop/netsurf.c
index cc823d4e9..822f81a77 100644
--- a/desktop/netsurf.c
+++ b/desktop/netsurf.c
@@ -121,7 +121,16 @@ void netsurf_init(int argc, char** argv)
void netsurf_poll(void)
{
- content_clean();
+ static unsigned int last_clean = 0;
+ unsigned int current_time = wallclock();
+
+ /* avoid calling content_clean() more often than once every 5
+ * seconds.
+ */
+ if (last_clean + 500 < current_time) {
+ last_clean = current_time;
+ content_clean();
+ }
gui_poll(fetch_active);
fetch_poll();
}