略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: LuaSandbox::setMemoryLimit

2024-05-17

LuaSandbox::setMemoryLimit

(PECL luasandbox >= 1.0.0)

LuaSandbox::setMemoryLimitSet the memory limit for the Lua environment

说明

public LuaSandbox::setMemoryLimit(int $limit): void

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->setMemoryLimit50 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

参见

add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/luasandbox.setmemorylimit.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3