(PECL luasandbox >= 1.0.0)
LuaSandbox::setMemoryLimit — 設定 Lua 環境的記憶體限制
limit
記憶體限制,單位為位元組。
無返回值。
範例 #1 呼叫 Lua 函式
<?php
// 建立新的 LuaSandbox
$sandbox = new LuaSandbox();
// 設定記憶體限制
$sandbox->setMemoryLimit( 50 * 1024 * 1024 );
// 執行 Lua 程式碼
$sandbox->loadString( 'local x = "x"; while true do x = x .. x; end' )->call();
?>
上述範例將輸出類似以下的內容
PHP Fatal error: Uncaught LuaSandboxMemoryError: not enough memory