lua-users home
lua-l archive

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


(1) Could be done using the C api in combination with a special allocator
function that tracks the memory use of the running coroutines. A simple query
function could return the current memory usage
(2) CPU cycles can be watched using the debug interfaces - it allows to call a
hook function (either C or Lua) in case of a certain condition, i.e. after a
certain number of instructions. However, this might slow down Lua. For
Competions etc. however, this behavior would be quite fair, as each user can
only use a limited amount of instructions.

Of course you can always limit the functions that the user can use by modifying
the environments of the the functions using setfenv. 


> Hey Everyone,
>   I'm working on a massive simulation project (like worldforge). I need to
> be able to allow users to script objects in the world. I am thinking of
> ussing Ruby as my scripting language of choice. However:
>   (1) I need to be able to limit the memory usage of the object.
>   (2) I need to be able to limit the CPU cycle usage of the object.
>   I.e. I don't want users to use my game to calculate digits of PI.
>   Is there a way to let me create these light-weight
> tasklets/threadlets/processlets (there's too many objects to have a UNIX
> process for each object) such that I can limit the memory/cpu usage on each?
> Thanks,