PHPackages                             sakanjo/memory-limited - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. sakanjo/memory-limited

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

sakanjo/memory-limited
======================

A package to limit the memory upon a function call.

v1.0.0(2y ago)761MITPHP

Since Jan 26Pushed 1y ago1 watchersCompare

[ Source](https://github.com/sakanjo/memory-limited)[ Packagist](https://packagist.org/packages/sakanjo/memory-limited)[ GitHub Sponsors](https://github.com/sakanjo)[ RSS](/packages/sakanjo-memory-limited/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Memory limited
==============

[](#memory-limited)

 [![PHP 8.0](https://camo.githubusercontent.com/2091ef06611f32d698bc7cc9a7331556f251f26d41ee5820639e6acabbe77ad0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e302d3737374242343f7374796c653d666f722d7468652d6261646765266c6f676f3d706870)](https://php.net)

Don't eat my memory please

> ✨ Help support the maintenance of this package by [sponsoring me](https://github.com/sponsors/sakanjo).

Table of contents
=================

[](#table-of-contents)

- [Install](#install)
- [Usage](#usage)
- [Support the development](#support-the-development)
- [Credits](#credits)
- [License](#license)

📦 Install
---------

[](#-install)

```
composer require --dev sakanjo/memory-limited

```

🦄 Usage
-------

[](#-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
-------------------------

[](#-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
----------

[](#️-credits)

- [Salah Kanjo](https://github.com/sakanjo)
- [All Contributors](../../contributors)

📄 License
---------

[](#-license)

[MIT License](https://github.com/sakanjo/sakanjo/memory-limited/blob/master/LICENSE) © 2023-PRESENT [Salah Kanjo](https://github.com/sakanjo)

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

833d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/121197517?v=4)[Salah Kanjo](/maintainers/sakanjo)[@sakanjo](https://github.com/sakanjo)

---

Top Contributors

[![sakanjo](https://avatars.githubusercontent.com/u/121197517?v=4)](https://github.com/sakanjo "sakanjo (4 commits)")

---

Tags

iniphpphpiniphp\_ini

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/sakanjo-memory-limited/health.svg)

```
[![Health](https://phpackages.com/badges/sakanjo-memory-limited/health.svg)](https://phpackages.com/packages/sakanjo-memory-limited)
```

###  Alternatives

[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21421.6k](/packages/imanghafoori-laravel-anypass)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
