https://github.com/sakanjo/memory-limited
A package to limit the memory upon a function call.
https://github.com/sakanjo/memory-limited
ini php
Last synced: 10 months ago
JSON representation
A package to limit the memory upon a function call.
- Host: GitHub
- URL: https://github.com/sakanjo/memory-limited
- Owner: sakanjo
- License: mit
- Created: 2024-01-26T18:57:39.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-05-14T15:53:15.000Z (about 2 years ago)
- Last Synced: 2024-11-28T03:46:29.817Z (over 1 year ago)
- Topics: ini, php
- Language: PHP
- Homepage:
- Size: 4.88 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
Memory limited
Don't eat my memory please
> ⨠Help support the maintenance of this package by [sponsoring me](https://github.com/sponsors/sakanjo).
Table of contents
=================
* [Install](#install)
* [Usage](#usage)
* [Support the development](#support-the-development)
* [Credits](#credits)
* [License](#license)
## đĻ Install
```
composer require --dev sakanjo/memory-limited
```
## đĻ Usage
```php
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"](https://github.com/sponsors/sakanjo) at the top of this repo.
## ÂŠī¸ Credits
- [Salah Kanjo](https://github.com/sakanjo)
- [All Contributors](../../contributors)
## đ License
[MIT License](https://github.com/sakanjo/sakanjo/memory-limited/blob/master/LICENSE) Š 2023-PRESENT [Salah Kanjo](https://github.com/sakanjo)