From d5e4fa21def90b6b4854d4a3bb3c822801c424cc Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Thu, 9 Aug 2007 10:14:32 +0000 Subject: [PATCH] memory indication. typo fix. git-svn-id: file:///svn/unbound/trunk@503 be551aaa-1e26-0410-a405-d3ace91eadb9 --- daemon/unbound.c | 6 ++++++ daemon/worker.c | 13 ++++++++++++- doc/Changelog | 2 ++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/daemon/unbound.c b/daemon/unbound.c index 8aa6d2314..ffcc4c094 100644 --- a/daemon/unbound.c +++ b/daemon/unbound.c @@ -55,6 +55,9 @@ #include #include +/** global debug value to keep track of heap memory allocation */ +void* unbound_start_brk = 0; + /** print usage. */ static void usage() { @@ -359,6 +362,9 @@ main(int argc, char* argv[]) int cmdline_verbose = 0; int debug_mode = 0; + /* take debug snapshot of heap */ + unbound_start_brk = sbrk(0); + log_init(NULL); /* parse the options */ while( (c=getopt(argc, argv, "c:dhv")) != -1) { diff --git a/daemon/worker.c b/daemon/worker.c index fbedcf1e5..e5d118057 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -69,6 +69,16 @@ /** Size of an UDP datagram */ #define NORMAL_UDP_SIZE 512 /* bytes */ +/** give debug heap size indication */ +static void +debug_total_mem() +{ + extern void* unbound_start_brk; + void* cur = sbrk(0); + int total = cur-unbound_start_brk; + log_info("Total heap memory estimate: %u", (unsigned)total); +} + /** Report on memory usage by this thread and global */ static void worker_mem_report(struct worker* worker) @@ -95,6 +105,7 @@ worker_mem_report(struct worker* worker) (unsigned)mesh, (unsigned)msg, (unsigned)rrset, (unsigned)infra, (unsigned)ac, (unsigned)superac, (unsigned)me); + debug_total_mem(); } void @@ -151,7 +162,7 @@ worker_handle_service_reply(struct comm_point* c, void* arg, int error, struct outbound_entry* e = (struct outbound_entry*)arg; struct worker* worker = e->qstate->env->worker; - verbose(VERB_ALGO, "worker scvd callback for qstate %p", e->qstate); + verbose(VERB_ALGO, "worker svcd callback for qstate %p", e->qstate); if(error != 0) { mesh_report_reply(worker->env.mesh, e, 0, reply_info); worker_mem_report(worker); diff --git a/doc/Changelog b/doc/Changelog index 189acf168..b567ebc05 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,6 +1,8 @@ 9 August 2007: Wouter - canonicalization, signature checks - dname signature label count and unit test. + - added debug heap size print to memory printout. + - typo fixup in worker.c 8 August 2007: Wouter - ldns _raw routines created (in ldns trunk). -- 2.47.2