summaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2006-12-03 22:34:26 +0000
committerJames Bursa <james@netsurf-browser.org>2006-12-03 22:34:26 +0000
commitb6b768f52153f95ed96980b3eb019d9eec340b6c (patch)
tree3c343c9d7b3215a991fa2aa666ed0b163c8ab760 /content
parentdb0aae2a469d179fffbbbb83acb649214f5dd9ec (diff)
downloadnetsurf-b6b768f52153f95ed96980b3eb019d9eec340b6c.tar.gz
netsurf-b6b768f52153f95ed96980b3eb019d9eec340b6c.tar.bz2
Improved tracking of memory usage. c->size is now exclusive of talloc size, and the two are added to find the full size.
svn path=/trunk/netsurf/; revision=3103
Diffstat (limited to 'content')
-rw-r--r--content/content.c11
-rw-r--r--content/content.h3
2 files changed, 6 insertions, 8 deletions
diff --git a/content/content.c b/content/content.c
index 5e915075e..0f23d25cc 100644
--- a/content/content.c
+++ b/content/content.c
@@ -373,7 +373,7 @@ struct content * content_create(const char *url)
c->refresh = 0;
c->bitmap = 0;
c->fresh = false;
- c->size = sizeof(struct content);
+ c->size = 0;
c->title = 0;
c->active = 0;
user_sentinel->callback = 0;
@@ -641,7 +641,6 @@ bool content_process_data(struct content *c, const char *data,
}
memcpy(c->source_data + c->source_size, data, size);
c->source_size += size;
- c->size += size;
if (handler_map[c->type].process_data) {
if (!handler_map[c->type].process_data(c,
@@ -701,8 +700,6 @@ void content_convert(struct content *c, int width, int height)
}
c->locked = false;
- c->size = talloc_total_size(c);
-
assert(c->status == CONTENT_STATUS_READY ||
c->status == CONTENT_STATUS_DONE);
content_broadcast(c, CONTENT_MSG_READY, msg_data);
@@ -779,14 +776,14 @@ void content_clean(void)
next = 0;
for (c = content_list; c; c = c->next) {
next = c;
- size += c->size;
+ size += c->size + talloc_total_size(c);
}
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;
+ size -= c->size + talloc_total_size(c);
content_destroy(c);
}
}
@@ -836,7 +833,7 @@ void content_reset(struct content *c)
handler_map[c->type].destroy(c);
c->type = CONTENT_UNKNOWN;
c->status = CONTENT_STATUS_TYPE_UNKNOWN;
- c->size = sizeof(struct content);
+ c->size = 0;
talloc_free(c->mime_type);
c->mime_type = 0;
}
diff --git a/content/content.h b/content/content.h
index aca53e448..123733ba9 100644
--- a/content/content.h
+++ b/content/content.h
@@ -180,7 +180,8 @@ struct content {
struct cache_data *cache_data; /**< Cache control data */
unsigned int size; /**< Estimated size of all data
- associated with this content. */
+ associated with this content, except
+ alloced as talloc children of this. */
char *title; /**< Title for browser window. */
unsigned int active; /**< Number of child fetches or
conversions currently in progress. */