diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-01-14 12:21:16 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-01-14 12:21:16 -0200 |
commit | 8e346d875ac1555bb3b008c99130792855a757a8 (patch) | |
tree | 44dff3c59a80baf352004a177e2c004e0fac011e /lmem.c | |
parent | 5be517602e5334573297fe8d421a92eb0184ce86 (diff) | |
download | lua-8e346d875ac1555bb3b008c99130792855a757a8.tar.gz lua-8e346d875ac1555bb3b008c99130792855a757a8.tar.bz2 lua-8e346d875ac1555bb3b008c99130792855a757a8.zip |
auxiliar patch to monitor garbage collection
Diffstat (limited to 'lmem.c')
-rw-r--r-- | lmem.c | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lmem.c,v 1.66 2004/11/19 15:52:40 roberto Exp roberto $ | 2 | ** $Id: lmem.c,v 1.67 2004/12/01 15:46:18 roberto Exp roberto $ |
3 | ** Interface to Memory Manager | 3 | ** Interface to Memory Manager |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -81,6 +81,22 @@ void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { | |||
81 | luaD_throw(L, LUA_ERRMEM); | 81 | luaD_throw(L, LUA_ERRMEM); |
82 | lua_assert((nsize == 0) == (block == NULL)); | 82 | lua_assert((nsize == 0) == (block == NULL)); |
83 | g->totalbytes = (g->totalbytes - osize) + nsize; | 83 | g->totalbytes = (g->totalbytes - osize) + nsize; |
84 | #if 0 | ||
85 | { /* auxiliar patch to monitor garbage collection */ | ||
86 | static unsigned long total = 0; /* our "time" */ | ||
87 | static lu_mem last = 0; /* last totalmem that generated an output */ | ||
88 | static FILE *f = NULL; /* output file */ | ||
89 | if (nsize <= osize) total += 1; /* "time" always grow */ | ||
90 | else total += (nsize - osize); | ||
91 | if ((int)g->totalbytes - (int)last > 1000 || | ||
92 | (int)g->totalbytes - (int)last < -1000) { | ||
93 | last = g->totalbytes; | ||
94 | if (f == NULL) f = fopen("trace", "w"); | ||
95 | fprintf(f, "%lu %u %u %u %d\n", total, g->totalbytes, g->GCthreshold, | ||
96 | g->estimate, g->gcstate); | ||
97 | } | ||
98 | } | ||
99 | #endif | ||
84 | return block; | 100 | return block; |
85 | } | 101 | } |
86 | 102 | ||