lua-users home
lua-l archive

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


Shawn Fox wrote:
..., but it really ought to be part of the standard API, like
lua_gc(L, LUA_GCMAXMEMORY, 67108864) or some such...

Try writing it! Once you become accustomed Lua's tightly-crafted source code, you'll probably find it no harder than using your own allocator. You already know that, I'm sure. If it's elegant enough then it might make its way into the source. And even if it doesn't make it into 5.2 in time for your current project, you'll at least be able to use the API that you like.

> ... The best case for me would be a new API call that allows me to
> specify a max memory and cpu usage, something like:
> lua_pcall_limit(L, nargs, nresults, errorfunction, maxmemory, maxcpu);

Enforcing a limit per pcall() seems much more difficult. Is maxcpu the number of VM instructions executed? Is it the underlying OS's version (non-ANSI)? What about previously existing objects collected during pcall()? Does the pcall() get to use that memory? And userdata?

All those questions (and others that will arise) could be answered. It seems complex enough to me that I wouldn't try it myself without a burning need (which you have). But if you can make it work, I assure you that many would be interested in the result!

Certainly much will be learned along the way.

Doug