PHP code example of sakanjo / memory-limited

1. Go to this page and download the library: Download sakanjo/memory-limited library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sakanjo / memory-limited example snippets


use function Sakanjo\MemoryLimited\run_memory_limited;

function memoryEater(): mixed
{
    return memoryEater();
}

run_memory_limited(mb: 20, callback: function() {
    memoryEater(); // It will throw FATAL when reaching 20M of memory, instead of hanging the system
});