[cvs] bogofilter/src memdebug.c,1.8,1.9
Fast Bayesian spam filter along lines suggested by Paul Graham
Brought to you by:
m-a
From: <re...@us...> - 2003-10-25 00:19:26
|
Update of /cvsroot/bogofilter/bogofilter/src In directory sc8-pr-cvs1:/tmp/cvs-serv3701 Modified Files: memdebug.c Log Message: Implement ability to report each MB of increased usage. Index: memdebug.c =================================================================== RCS file: /cvsroot/bogofilter/bogofilter/src/memdebug.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- memdebug.c 14 Oct 2003 19:13:55 -0000 1.8 +++ memdebug.c 25 Oct 2003 00:12:12 -0000 1.9 @@ -30,7 +30,7 @@ int memtrace= 0 * (M_MALLOC+M_FREE); -uint32_t dbg_index = 0; +uint32_t dbg_trap_index= 0; uint32_t dbg_size = 0; uint32_t dbg_index_min = 0; uint32_t dbg_index_max = 0; @@ -40,6 +40,9 @@ #define GB 1000*MB uint32_t dbg_too_much = 0; /* GB */ +uint32_t dbg_size_delt = 0; /* MB */ +uint32_t dbg_delt_save = 0; + const uint32_t md_tag = 0xABCD55AA; uint32_t cnt_malloc = 0; @@ -79,6 +82,13 @@ ++cnt_malloc; cur_malloc += size; + + if (dbg_size_delt != 0 && + max_malloc - dbg_delt_save > dbg_size_delt) { + dbg_delt_save = max_malloc / dbg_size_delt * dbg_size_delt; + fprintf(dbgout, ":: max_malloc = %12lu\n", (ulong) max_malloc); + } + max_malloc = max(max_malloc, cur_malloc); tot_malloc += size; size += sizeof(mh_t); /* Include size storage */ @@ -100,7 +110,7 @@ if (memtrace & M_MALLOC) mh_disp( "a", mh ); - if (dbg_index != 0 && mh->indx == dbg_index) + if (dbg_trap_index != 0 && mh->indx == dbg_trap_index) md_trap("dbg_index"); x = (void *) (mh+1); @@ -124,8 +134,8 @@ if (mh->tag != md_tag) md_trap("md_tag"); - if (dbg_index != 0 && mh->indx == dbg_index) - md_trap("dbg_index"); + if (dbg_trap_index != 0 && mh->indx == dbg_trap_index) + md_trap("dbg_trap_index"); if (mh->size > cur_malloc || (dbg_size_trap != 0 && mh->size > dbg_size_trap)) md_trap("dbg_size_trap"); @@ -143,17 +153,17 @@ if (file != NULL) { pfx = "\t"; - fprintf(stdout, "%s:%d:\n", file, lineno); + fprintf(dbgout, "%s:%d:\n", file, lineno); } - fprintf(stdout, "%smalloc: cur = %lu, max = %lu, tot = %lu\n", pfx, + fprintf(dbgout, "%smalloc: cur = %lu, max = %lu, tot = %lu\n", pfx, (ulong) cur_malloc, (ulong) max_malloc, (ulong) tot_malloc ); - fprintf(stdout, "%scounts: malloc: %lu, calloc: %lu, realloc: %lu, free: %lu\n", pfx, + fprintf(dbgout, "%scounts: malloc: %lu, calloc: %lu, realloc: %lu, free: %lu\n", pfx, (ulong) cnt_malloc, (ulong) cnt_realloc, (ulong) cnt_calloc, (ulong) cnt_free); if (cnt_malloc == cnt_free) - fprintf(stdout, "%s none active.\n", pfx); + fprintf(dbgout, "%s none active.\n", pfx); else - fprintf(stdout, "%s active: %lu, average: %lu\n", pfx, + fprintf(dbgout, "%s active: %lu, average: %lu\n", pfx, (ulong) cnt_malloc - cnt_free, (ulong) cur_malloc/(cnt_malloc - cnt_free)); } @@ -186,8 +196,8 @@ if (memtrace & M_MALLOC) mh_disp( "c", mh ); - if (dbg_index != 0 && mh->indx == dbg_index) - md_trap("dbg_index"); + if (dbg_trap_index != 0 && mh->indx == dbg_trap_index) + md_trap("dbg_trap_index"); x = (void *) (mh+1); |