mirror of
https://github.com/lua/lua
synced 2024-11-22 12:51:30 +03:00
more information about memory use
This commit is contained in:
parent
06f08f5634
commit
87367e97f3
4
lmem.c
4
lmem.c
@ -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
3
lmem.h
@ -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
|
||||
|
||||
|
||||
|
3
ltests.c
3
ltests.c
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user