diff options
author | M. Kristall <mkpdev@gmail.com> | 2009-10-19 21:00:09 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:16:57 +0000 |
commit | 8a0677cf7a26f6a4dffc42b747da7e5ff754f386 (patch) | |
tree | adf17b3f71fa6ffe2ea3af52a675b6229ee57af6 /src/game/bg_alloc.c | |
parent | 92a9136413e1d246838a3b8ff7e67f724ee29706 (diff) |
* Add game_memory and cgame_memory commands to give a breakdown of memory
* Make clientlist team colors more consistent with team colors elsewhere
Diffstat (limited to 'src/game/bg_alloc.c')
-rw-r--r-- | src/game/bg_alloc.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/game/bg_alloc.c b/src/game/bg_alloc.c index 080bf83a..d8849d16 100644 --- a/src/game/bg_alloc.c +++ b/src/game/bg_alloc.c @@ -202,3 +202,40 @@ void BG_DefragmentMemory( void ) startfmn = startfmn->next; // endfmn acts as a 'restart' flag here } } + +void BG_MemoryInfo( void ) +{ + // Give a breakdown of memory + + freeMemNode_t *fmn = (freeMemNode_t *)memoryPool; + int size, chunks; + freeMemNode_t *end = (freeMemNode_t *)( memoryPool + POOLSIZE ); + void *p; + + Com_Printf( "%p-%p: %d out of %d bytes allocated\n", + fmn, end, POOLSIZE - freeMem, POOLSIZE ); + + while( fmn < end ) + { + size = chunks = 0; + p = fmn; + while( fmn < end && fmn->cookie == FREEMEMCOOKIE ) + { + size += fmn->size; + chunks++; + fmn = (freeMemNode_t *)( (char *)fmn + fmn->size ); + } + if( size ) + Com_Printf( " %p: %d bytes free (%d chunks)\n", p, size, chunks ); + size = chunks = 0; + p = fmn; + while( fmn < end && fmn->cookie != FREEMEMCOOKIE ) + { + size += *(int *)fmn; + chunks++; + fmn = (freeMemNode_t *)( (size_t)fmn + *(int *)fmn ); + } + if( size ) + Com_Printf( " %p: %d bytes allocated (%d chunks)\n", p, size, chunks ); + } +} |