aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2010-09-13 19:48:31 +0200
committerMike Pall <mike>2010-09-13 19:48:31 +0200
commit32bfececc59a962a0803a620572294bcefec37e4 (patch)
treee78ed9f6b399ece18a52258b9fd1e49ef9acf043 /src
parentc88169dc4672faa26d7e0ac9b1bf810a5d0534f4 (diff)
downloadluajit-32bfececc59a962a0803a620572294bcefec37e4.tar.gz
luajit-32bfececc59a962a0803a620572294bcefec37e4.tar.bz2
luajit-32bfececc59a962a0803a620572294bcefec37e4.zip
Release all memory when using the builtin allocator.
Blocks >128K are not kept in the segment list and were not destroyed.
Diffstat (limited to 'src')
-rw-r--r--src/lj_state.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/src/lj_state.c b/src/lj_state.c
index f7647f33..91f35638 100644
--- a/src/lj_state.c
+++ b/src/lj_state.c
@@ -155,26 +155,21 @@ static TValue *cpluaopen(lua_State *L, lua_CFunction dummy, void *ud)
155static void close_state(lua_State *L) 155static void close_state(lua_State *L)
156{ 156{
157 global_State *g = G(L); 157 global_State *g = G(L);
158 lj_func_closeuv(L, tvref(L->stack));
159 lj_gc_freeall(g);
160 lua_assert(gcref(g->gc.root) == obj2gco(L));
161 lua_assert(g->strnum == 0);
162 lj_trace_freestate(g);
163 lj_mem_freevec(g, g->strhash, g->strmask+1, GCRef);
164 lj_str_freebuf(g, &g->tmpbuf);
165 lj_mem_freevec(g, tvref(L->stack), L->stacksize, TValue);
166 lua_assert(g->gc.total == sizeof(GG_State));
158#ifndef LUAJIT_USE_SYSMALLOC 167#ifndef LUAJIT_USE_SYSMALLOC
159 if (g->allocf == lj_alloc_f) { 168 if (g->allocf == lj_alloc_f)
160#if LJ_HASJIT
161 lj_mcode_free(G2J(g));
162#endif
163 lj_alloc_destroy(g->allocd); 169 lj_alloc_destroy(g->allocd);
164 } else 170 else
165#endif 171#endif
166 {
167 lj_func_closeuv(L, tvref(L->stack));
168 lj_gc_freeall(g);
169 lua_assert(gcref(g->gc.root) == obj2gco(L));
170 lua_assert(g->strnum == 0);
171 lj_trace_freestate(g);
172 lj_mem_freevec(g, g->strhash, g->strmask+1, GCRef);
173 lj_str_freebuf(g, &g->tmpbuf);
174 lj_mem_freevec(g, tvref(L->stack), L->stacksize, TValue);
175 lua_assert(g->gc.total == sizeof(GG_State));
176 g->allocf(g->allocd, G2GG(g), sizeof(GG_State), 0); 172 g->allocf(g->allocd, G2GG(g), sizeof(GG_State), 0);
177 }
178} 173}
179 174
180#if LJ_64 175#if LJ_64