array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'fr', ), 'this' => array ( 0 => 'luasandbox.setmemorylimit.php', 1 => 'LuaSandbox::setMemoryLimit', ), 'up' => array ( 0 => 'class.luasandbox.php', 1 => 'LuaSandbox', ), 'prev' => array ( 0 => 'luasandbox.setcpulimit.php', 1 => 'LuaSandbox::setCPULimit', ), 'next' => array ( 0 => 'luasandbox.unpauseusagetimer.php', 1 => 'LuaSandbox::unpauseUsageTimer', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/luasandbox/luasandbox/setmemorylimit.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(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.
Aucune valeur n'est retournée.
Exemple #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();
?>
Résultat de l'exemple ci-dessus est similaire à :
PHP Fatal error: Uncaught LuaSandboxMemoryError: not enough memory