update page now

LuaSandbox::setMemoryLimit

(PECL luasandbox >= 1.0.0)

LuaSandbox::setMemoryLimitSet the memory limit for the Lua environment

Descrizione

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

Sets the memory limit for the Lua environment.

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

Elenco dei parametri

limit

Memory limit in bytes.

Valori restituiti

Nessun valore viene restituito.

Esempi

Example #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();

?>

Il precedente esempio visualizzerà qualcosa simile a:

PHP Fatal error:  Uncaught LuaSandboxMemoryError: not enough memory

Vedere anche:

add a note

User Contributed Notes

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

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant