From acb60628f53ba1fc29d1a554683acdb03f961c6f Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Wed, 2 Jun 2010 22:20:40 +0200 Subject: Implements command that shows memory usage. --- lib/resource.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/resource.h') diff --git a/lib/resource.h b/lib/resource.h index 8dd441f0..5cb5e274 100644 --- a/lib/resource.h +++ b/lib/resource.h @@ -26,8 +26,12 @@ struct resclass { void (*free)(resource *); /* Freeing function */ void (*dump)(resource *); /* Dump to debug output */ resource *(*lookup)(resource *, unsigned long); /* Look up address (only for debugging) */ + size_t (*memsize)(resource *); /* Return size of memory used by the resource, may be NULL */ }; +/* Estimate of system allocator overhead per item, for memory consumtion stats */ +#define ALLOC_OVERHEAD 8 + /* Generic resource manipulation */ typedef struct pool pool; @@ -36,6 +40,7 @@ void resource_init(void); pool *rp_new(pool *, char *); /* Create new pool */ void rfree(void *); /* Free single resource */ void rdump(void *); /* Dump to debug output */ +size_t rmemsize(void *res); /* Return size of memory used by the resource */ void rlookup(unsigned long); /* Look up address (only for debugging) */ void rmove(void *, pool *); /* Move to a different pool */ -- cgit v1.2.3