(PECL luasandbox >= 1.0.0)
LuaSandbox::setMemoryLimit — Set the memory limit for the Lua environment
Sets the memory limit for the Lua environment.
If this limit is exceeded, a LuaSandboxMemoryError exception is thrown.
limit
Memory limit in bytes.
No devuelve ningún valor.
Ejemplo #1 Calling a Lua function
<?php
// create a new LuaSandbox
$sandbox = new LuaSandbox();
// set a memory limit
$sandbox->setMemoryLimit( 50 * 1024 * 1024 );
// Run Lua code
$sandbox->loadString( 'local x = "x"; while true do x = x .. x; end' )->call();
?>
El resultado del ejemplo sería algo similar a:
PHP Fatal error: Uncaught LuaSandboxMemoryError: not enough memory