LuaSandbox::setMemoryLimit
(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.
返回值
没有返回值。
示例
示例 #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();
?>
以上示例的输出类似于:
PHP Fatal error: Uncaught LuaSandboxMemoryError: not enough memory
参见
- LuaSandbox::getMemoryUsage() - Fetch the current memory usage of the Lua environment
- LuaSandbox::getPeakMemoryUsage() - Fetch the peak memory usage of the Lua environment
- LuaSandbox::setCPULimit() - Set the CPU time limit for the Lua environment
+添加备注
用户贡献的备注
此页面尚无用户贡献的备注。
备份地址:http://www.lvesu.com/blog/php/luasandbox.setmemorylimit.php