Skip to content

A package to limit the memory upon a function call.

License

Notifications You must be signed in to change notification settings

sakanjo/memory-limited

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Memory limited

PHP 8.0

Don't eat my memory please

✨ Help support the maintenance of this package by sponsoring me.

Table of contents

📦 Install

composer require --dev sakanjo/memory-limited

🦄 Usage

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
});

Voila, that's it!

Pay attention that this package is only used in development mode for testing purposes, it will throw Fatal error when the memory limit is reached.

💖 Support the development

Do you like this project? Support it by donating

Click the "💖 Sponsor" at the top of this repo.

©️ Credits

📄 License

MIT License © 2023-PRESENT Salah Kanjo

About

A package to limit the memory upon a function call.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Languages