lua-users home
lua-l archive

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


Quoth Shawn Fox <shawnkfox@gmail.com>, on 2010-08-14 20:31:38 -0500:
> Any chance of adding a way to set a memory cap?  This would be very useful
> for me and I'd think others who are building sandbox type environments would
> find it useful as well.  I'm using a custom memory allocator right now to
> cap memory usage, but it really ought to be part of the standard API, like
> lua_gc(L, LUA_GCMAXMEMORY, 67108864) or some such...

I'm a little suspicious.  It seems like the kind of convenience
function that would be hanging off the side of the rest of the GC
settings without actually belonging there.  I tend to think the
allocator hooks are good enough for that; besides, that would let you
do things like soft and hard limits of any form you like (so, free up
an emergency allocation for recovering when your initial cap runs out,
&c.), and then modify the behavior as necessary for the application.
I think a single hard memory cap isn't as useful as it might seem, and
anything more complicated would get into significant complexity for a
feature that's not very cohesive with the rest of Lua core.

Just one person's opinion though.  :-)

   ---> Drake Wilson