mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-22 14:31:20 +03:00
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
This commit is contained in:
parent
db0aae2a46
commit
b6b768f521
@ -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;
|
||||
}
|
||||
|
@ -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. */
|
||||
|
@ -359,8 +359,6 @@ bool html_convert(struct content *c, int width, int height)
|
||||
html_reformat(c, width, height);
|
||||
/*box_dump(c->data.html.layout->children, 0);*/
|
||||
|
||||
c->size = talloc_total_size(c);
|
||||
|
||||
if (c->active == 0) {
|
||||
c->status = CONTENT_STATUS_DONE;
|
||||
content_set_status(c, messages_get("Done"));
|
||||
|
@ -2,7 +2,7 @@
|
||||
* This file is part of NetSurf, http://netsurf-browser.org/
|
||||
* Licensed under the GNU General Public License,
|
||||
* http://www.opensource.org/licenses/gpl-license
|
||||
* Copyright 2004 James Bursa <bursa@users.sourceforge.net>
|
||||
* Copyright 2006 James Bursa <bursa@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
/** \file
|
||||
@ -16,6 +16,7 @@
|
||||
#include "netsurf/riscos/dialog.h"
|
||||
#include "netsurf/riscos/wimp_event.h"
|
||||
#include "netsurf/utils/log.h"
|
||||
#include "netsurf/utils/talloc.h"
|
||||
#include "netsurf/utils/utils.h"
|
||||
|
||||
/** Update interval / cs. */
|
||||
@ -52,7 +53,7 @@ void ro_gui_debugwin_resize(void)
|
||||
|
||||
box.x0 = 0;
|
||||
box.y0 = -count * 28;
|
||||
box.x1 = 1200;
|
||||
box.x1 = 1400;
|
||||
box.y1 = 0;
|
||||
error = xwimp_set_extent(dialog_debug, &box);
|
||||
if (error) {
|
||||
@ -118,12 +119,13 @@ void ro_gui_debugwin_redraw(wimp_draw *redraw)
|
||||
|
||||
void ro_gui_debugwin_redraw_plot(wimp_draw *redraw)
|
||||
{
|
||||
char s[20];
|
||||
char s[40];
|
||||
int x0 = redraw->box.x0 - redraw->xscroll;
|
||||
int y0 = redraw->box.y1 - redraw->yscroll;
|
||||
int i = 1;
|
||||
int y;
|
||||
unsigned int users;
|
||||
unsigned int talloc_size;
|
||||
unsigned int size = 0;
|
||||
struct content *content;
|
||||
struct content_user *user;
|
||||
@ -156,10 +158,12 @@ void ro_gui_debugwin_redraw_plot(wimp_draw *redraw)
|
||||
xwimptextop_paint(wimptextop_RJUSTIFY, s, x0 + 960, y);
|
||||
xwimptextop_paint(0, content_status_name[content->status],
|
||||
x0 + 990, y);
|
||||
snprintf(s, sizeof s, "%u", content->size);
|
||||
xwimptextop_paint(wimptextop_RJUSTIFY, s, x0 + 1190, y);
|
||||
size += content->size;
|
||||
talloc_size = talloc_total_size(content);
|
||||
snprintf(s, sizeof s, "%u+%u=%u", content->size, talloc_size,
|
||||
content->size + talloc_size);
|
||||
xwimptextop_paint(wimptextop_RJUSTIFY, s, x0 + 1390, y);
|
||||
size += content->size + talloc_size;
|
||||
}
|
||||
snprintf(s, sizeof s, "%u", size);
|
||||
xwimptextop_paint(wimptextop_RJUSTIFY, s, x0 + 1190, y0 - i * 28 - 20);
|
||||
xwimptextop_paint(wimptextop_RJUSTIFY, s, x0 + 1390, y0 - i * 28 - 20);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user