Commit 950d71ee authored by Mark Andrews's avatar Mark Andrews
Browse files

allow maximum inuse memory to be tracked.

parent 6817b32d
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: mem.h,v 1.52 2001/06/06 21:02:43 bwelling Exp $ */
/* $Id: mem.h,v 1.53 2001/06/27 23:29:29 marka Exp $ */
#ifndef ISC_MEM_H
#define ISC_MEM_H 1
......@@ -82,10 +82,14 @@ typedef void (*isc_memfree_t)(void *, void *);
* _DEBUGRECORD
* remember each allocation, and match them up on free. Crash if
* a free doesn't match an allocation
* _DEBUGUSAGE
* if a hi_water mark is set print the maximium inuse memory every
* time it is raised once it exceeds the hi_water mark
*/
extern unsigned int isc_mem_debugging;
#define ISC_MEM_DEBUGTRACE 0x00000001U
#define ISC_MEM_DEBUGRECORD 0x00000002U
#define ISC_MEM_DEBUGUSAGE 0x00000004U
#if ISC_MEM_TRACKLINES
#define _ISC_MEM_FILELINE , __FILE__, __LINE__
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: mem.c,v 1.93 2001/06/11 20:27:16 gson Exp $ */
/* $Id: mem.c,v 1.94 2001/06/27 23:29:27 marka Exp $ */
#include <config.h>
......@@ -118,6 +118,7 @@ struct isc_mem {
size_t quota;
size_t total;
size_t inuse;
size_t maxinuse;
size_t hi_water;
size_t lo_water;
isc_boolean_t hi_called;
......@@ -700,6 +701,7 @@ isc_mem_createx(size_t init_max_size, size_t target_size,
ctx->quota = 0;
ctx->total = 0;
ctx->inuse = 0;
ctx->maxinuse = 0;
ctx->hi_water = 0;
ctx->lo_water = 0;
ctx->hi_called = ISC_FALSE;
......@@ -985,6 +987,12 @@ isc__mem_get(isc_mem_t *ctx, size_t size FLARG) {
ctx->hi_called = ISC_TRUE;
call_water = ISC_TRUE;
}
if (ctx->inuse > ctx->maxinuse) {
ctx->maxinuse = ctx->inuse;
if (ctx->hi_water != 0 && ctx->inuse > ctx->hi_water &&
(isc_mem_debugging & ISC_MEM_DEBUGUSAGE) != 0)
fprintf(stderr, "maxinuse = %d\n", ctx->inuse);
}
UNLOCK(&ctx->lock);
if (call_water) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment