summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/game')
-rw-r--r--src/game/bg_alloc.c37
-rw-r--r--src/game/bg_public.h1
-rw-r--r--src/game/g_svcmds.c1
3 files changed, 39 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 );
+ }
+}
diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index e952624a..fa6d24b7 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -1212,6 +1212,7 @@ void *BG_Alloc( int size );
void BG_InitMemory( void );
void BG_Free( void *ptr );
void BG_DefragmentMemory( void );
+void BG_MemoryInfo( void );
void BG_EvaluateTrajectory( const trajectory_t *tr, int atTime, vec3_t result );
void BG_EvaluateTrajectoryDelta( const trajectory_t *tr, int atTime, vec3_t result );
diff --git a/src/game/g_svcmds.c b/src/game/g_svcmds.c
index f75236ed..20f95bbd 100644
--- a/src/game/g_svcmds.c
+++ b/src/game/g_svcmds.c
@@ -530,6 +530,7 @@ struct svcmd
{ "entityList", qfalse, Svcmd_EntityList_f },
{ "evacuation", qfalse, Svcmd_Evacuation_f },
{ "forceTeam", qfalse, Svcmd_ForceTeam_f },
+ { "game_memory", qfalse, BG_MemoryInfo },
{ "humanWin", qfalse, Svcmd_TeamWin_f },
{ "layoutLoad", qfalse, Svcmd_LayoutLoad_f },
{ "layoutSave", qfalse, Svcmd_LayoutSave_f },