LuaSandbox::setMemoryLimit

(PECL luasandbox >= 1.0.0)

LuaSandbox::setMemoryLimitSet the memory limit for the Lua environment

Description

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

Sets the memory limit for the Lua environment.

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

Liste de paramètres

limit

Memory limit in bytes.

Valeurs de retour

Aucune valeur n'est retournée.

Exemples

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

?>

L'exemple ci-dessus va afficher quelque chose de similaire à :

PHP Fatal error:  Uncaught LuaSandboxMemoryError: not enough memory

Voir aussi