aboutsummaryrefslogtreecommitdiff
path: root/lmem.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-05-04 15:10:02 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-05-04 15:10:02 -0300
commite7ce7e1850551e40f7a86713c9068f9d4e414d00 (patch)
treea294ad337951dd4b36cacec5c4ad4a32cb88788e /lmem.c
parent3e662cec89fa928122873ff302ed2c39217d4710 (diff)
downloadlua-e7ce7e1850551e40f7a86713c9068f9d4e414d00.tar.gz
lua-e7ce7e1850551e40f7a86713c9068f9d4e414d00.tar.bz2
lua-e7ce7e1850551e40f7a86713c9068f9d4e414d00.zip
changes in patch to monitor garbage collection
Diffstat (limited to 'lmem.c')
-rw-r--r--lmem.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/lmem.c b/lmem.c
index 0dc4d10d..90ab0588 100644
--- a/lmem.c
+++ b/lmem.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lmem.c,v 1.76 2010/04/29 17:33:17 roberto Exp roberto $ 2** $Id: lmem.c,v 1.77 2010/04/30 18:17:24 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*/
@@ -103,18 +103,14 @@ void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) {
103 ** plot TRACEMEM using 1:2 with lines, TRACEMEM using 1:3 with lines 103 ** plot TRACEMEM using 1:2 with lines, TRACEMEM using 1:3 with lines
104 */ 104 */
105 static unsigned long total = 0; /* our "time" */ 105 static unsigned long total = 0; /* our "time" */
106 static lu_mem last = 0; /* last totalmem that generated an output */
107 static FILE *f = NULL; /* output file */ 106 static FILE *f = NULL; /* output file */
108 if (nsize <= osize) total += 1; /* "time" always grow */ 107 total++; /* "time" always grow */
109 else total += (nsize - osize); 108 if ((total % 200) == 0) {
110 if ((int)g->totalbytes - (int)last > 1000 ||
111 (int)g->totalbytes - (int)last < -1000) {
112 last = g->totalbytes;
113 if (f == NULL) f = fopen(TRACEMEM, "w"); 109 if (f == NULL) f = fopen(TRACEMEM, "w");
114 fprintf(f, "%lu %u %u %d\n", total, 110 fprintf(f, "%lu %u %d %d\n", total,
115 g->totalbytes, 111 g->totalbytes,
116 g->GCthreshold < MAX_LUMEM ? g->GCthreshold : 0, 112 gcstopped(g) ? 0 : g->GCdebt,
117 g->gcstate); 113 g->gcstate * 1000);
118 } 114 }
119 } 115 }
120#endif 116#endif