more information about memory use

This commit is contained in:
Roberto Ierusalimschy 2000-03-16 17:35:07 -03:00
parent 06f08f5634
commit 87367e97f3
3 changed files with 7 additions and 3 deletions

4
lmem.c
View File

@ -1,5 +1,5 @@
/*
** $Id: lmem.c,v 1.27 2000/03/10 14:01:05 roberto Exp roberto $
** $Id: lmem.c,v 1.28 2000/03/10 18:37:44 roberto Exp roberto $
** Interface to Memory Manager
** See Copyright Notice in lua.h
*/
@ -54,6 +54,7 @@
unsigned long memdebug_numblocks = 0;
unsigned long memdebug_total = 0;
unsigned long memdebug_maxmem = 0;
static void *checkblock (void *block) {
@ -95,6 +96,7 @@ static void *debug_realloc (void *block, size_t size) {
freeblock(block); /* erase (and check) old copy */
}
memdebug_total += size;
if (memdebug_total > memdebug_maxmem) memdebug_maxmem = memdebug_total;
memdebug_numblocks++;
*(unsigned long *)newblock = size;
for (i=0;i<MARKSIZE;i++)

3
lmem.h
View File

@ -1,5 +1,5 @@
/*
** $Id: lmem.h,v 1.11 1999/12/27 17:33:22 roberto Exp roberto $
** $Id: lmem.h,v 1.12 2000/01/13 16:30:47 roberto Exp roberto $
** Interface to Memory Manager
** See Copyright Notice in lua.h
*/
@ -36,6 +36,7 @@ void *luaM_growaux (lua_State *L, void *block, unsigned long nelems, int inc, in
#ifdef DEBUG
extern unsigned long memdebug_numblocks;
extern unsigned long memdebug_total;
extern unsigned long memdebug_maxmem;
#endif

View File

@ -1,5 +1,5 @@
/*
** $Id: ltests.c,v 1.8 2000/02/21 18:30:06 roberto Exp roberto $
** $Id: ltests.c,v 1.9 2000/03/10 18:37:44 roberto Exp roberto $
** Internal Module for Debugging of the Lua Implementation
** See Copyright Notice in lua.h
*/
@ -33,6 +33,7 @@ void luaB_opentests (lua_State *L);
static void mem_query (lua_State *L) {
lua_pushnumber(L, memdebug_total);
lua_pushnumber(L, memdebug_numblocks);
lua_pushnumber(L, memdebug_maxmem);
}