lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Ok here's a simple script and how were running it...  lets assumed its

-- our script

//-  now our function is this..

static int Print(lua_State *L)
    int n=lua_gettop(L);
    int i;

    printf("Running Script Command : Print\n");
    for (i=1; i<=n; i++)
        if (i>1)
            printf("     ");
        if (lua_isstring(L,i))

    return 0;

// - now this function is in a lib, heres the mappings.

static const struct luaL_reg Our_funcs[] =

LUALIB_API void lua_Ourlibopen (lua_State *L)
  luaL_openl(L, Our_funcs);

// - to run this pre compiled script were calling... note gLState has been
// and some globals (3 in this case) added to it before running these

iReturn = lua_dobuffer (gLState,buff,size,name);

// now after doing this our memory prints keep going up.. and taking a look
at the
// check garbage collector it seems that as nblocks is << threshold for this
// and when we call lua_dobuffer it runs the protected parser which does

old_blocks = L->nblocks;
status = luaD_runprotected(L, f_parser, &p);
if (status == 0) {
    /* add new memory to threshold (as it probably will stay) */
    L->GCthreshold += (L->nblocks - old_blocks);

// this adding to the threshold constantly makes it luaC_checkGC(L); not
clean up next time around
// until I'm out of memory... so I had to call this after the do_buffer to
fix it.


-----Original Message-----
From: []
On Behalf Of Roberto Ierusalimschy
Sent:	Friday, January 26, 2001 10:56 AM
To:	Multiple recipients of list
Subject:	Re: .. garbage collection...

> Hi I'm fairly new to lua and just had a quick question for you guys.  I'm
> running a single lua state with a bunch of precompiled small lua scripts.
> Now the problem I had was that a single script never went anywhere close
> the default garbage collection threshold.  When running another script
> though the threshold was bumped up once again, this eventually cascades
> until I'm out of memory (small memory model constraints for what I'm

Could you send us a minimum version of the scripts that reproduce the
problem? That should not happen :-(

-- Roberto