lua-users home
lua-l archive

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

>I am working on a design for a persistent system which interprets lua files.
>In order to effect a speedup, I want to cache the compiled lua Proto
>objects. It seems to me that the best way to do this is to dump them (like
>luac does) and then keep the dump around in memory so I can undump it into
>any of the lua states I want, whenever I want to.

In 4.1, you have loadfile and loadbuffer leave precompiled stuff in the stack.
If you want the exact binary representation used by luac, use ldumplib.c in

>I need to know, because if this would introduce a memory leak, I need to
>address the issues :)

strip in luac.c does not care about freeing, because luac is a standalone
program. If you copy the code of strip into your application unchanged, it
will leak memory. To fix this, add these lines at the beginning of strip:

  luaM_freearray(L, f->lineinfo, f->sizelineinfo, int);
  luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar);

(these are from luaF_freeproto in lfunc.c.)