PHP 8.1.28 Released!

LuaSandbox::setMemoryLimit

(PECL luasandbox >= 1.0.0)

LuaSandbox::setMemoryLimitSet the memory limit for the Lua environment

Açıklama

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

Sets the memory limit for the Lua environment.

If this limit is exceeded, a LuaSandboxMemoryError exception is thrown.

Bağımsız Değişkenler

limit

Memory limit in bytes.

Dönen Değerler

Hiçbir değer dönmez.

Örnekler

Örnek 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();

?>

Yukarıdaki örnek şuna benzer bir çıktı üretir:

PHP Fatal error:  Uncaught LuaSandboxMemoryError: not enough memory

Ayrıca Bakınız

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top