lua-users home
lua-l archive

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


On Thu, Oct 09, 2003 at 11:39:45AM -0300, Luiz Henrique de Figueiredo wrote:
> I see two ways of doing this without patching Lua:
> 
> 1. In your count (or other) hook, call lua_getgccount and raise an error
>    if too much memory is being used.

I considered this, but if I track memory usage as well the hook needs
to be called every few instructions (instead of once for CPU limiting)
and maintain its own instruction count in the registry. This just
seems to complicate things and give a performance hit.

> 2. Recompile lmem.c to use your own memory allocator that refuses to allocate
>    too much memory.

I need to limit memory on a per lua_State basis. My own allocator
wouldn't easily know which lua_State it was called from unless lmem.c
was patched. Since lua_State already tracks memory usage the most
elegant way to provide memory limit functionality appears to be
doing the check in lmem.c.

Regards,
Mark

-- 
Mark Pulford <mark@kyne.com.au>    I'd give my right arm to be ambidextrous