lua-users home
lua-l archive

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


>Basically we are:
>1) Getting a pre-compiled buffer area(hashed via an id)
>2) running it using lua_dobuffer
>3) In the script it may call out to C function which
>   will get another piece of pre-compiled code which get executed
>(using the same L state passed to the C function)
>4) returns to the main 'calling script'

Every time you call lua_dobuffer, many things are allocated (it does not
really matter whether the buffers contain pre-compiled code or source text),
even if you call lua_dobuffer on the same buffer more than once. Of course,
everything should be collected when it becomes garbage. There should be no
leak.

Bottom line: calling lua_dobuffer (or lua_dostring or lua_dofile) always
allocates memory to hold the objects created by the chunks executed by
this call. Did you expect otherwise?

On the other hand, we are aware that if you're running lua_dobuffer on
static buffers than you might expect that there would be no need to duplicate
the data there. This is a reasonable expectation but at present data is
duplicated. We are looking for a good solution to this problem, but like I
said, string values in Lua for instance assume that their string data and
their header data are contiguous but strings in pre-compiled chunks only
have the string data part, naturally.
--lhf