PHPackages                             shipmonk/memory-scanner - 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. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. shipmonk/memory-scanner

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

shipmonk/memory-scanner
=======================

Lightweight PHP library for analyzing memory usage, tracking object references, and debugging memory leaks

1.0.0(1y ago)1729.5k↑330.6%2MITPHPPHP ^8.2CI passing

Since May 13Pushed 7mo ago2 watchersCompare

[ Source](https://github.com/shipmonk-rnd/memory-scanner)[ Packagist](https://packagist.org/packages/shipmonk/memory-scanner)[ RSS](/packages/shipmonk-memory-scanner/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (17)Versions (2)Used By (2)

ShipMonk PHP Memory Scanner
===========================

[](#shipmonk-php-memory-scanner)

A lightweight PHP library for analyzing memory usage and finding memory leaks in PHP applications.

This package provides tools to:

1. Scan PHP memory for objects and their references
2. Track object allocations and detect objects that aren't properly deallocated
3. Find reference paths from global roots to leaked objects
4. Generate detailed explanations of why objects aren't being deallocated

The core functionality relies on traversing the PHP object graph from various memory roots (like superglobals, functions, classes, etc.) to detect what's keeping your objects in memory.

Perfect for debugging memory leaks in long-running PHP applications, especially when working with frameworks or code that maintains complex object relationships.

Usage with Symfony &amp; PHPUnit
--------------------------------

[](#usage-with-symfony--phpunit)

In any test that extends `KernelTestCase`, you can use the trait `ObjectDeallocationCheckerKernelTestCaseTrait` to enable memory leak detection. This requires PHPUnit 11 or higher.

```
use ShipMonk\MemoryScanner\Bridge\PHPUnit\ObjectDeallocationCheckerKernelTestCaseTrait;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class HomepageControllerTest extends WebTestCase
{
    use ObjectDeallocationCheckerKernelTestCaseTrait;

    public function testHomepageOk(): void
    {
        self::createClient()->request('GET', '/');
        self::assertResponseIsSuccessful();
    }
}
```

Manual Usage
------------

[](#manual-usage)

You can also use the library manually in any PHP script. Here's a simple example:

```
$objectDeallocationChecker = new \ShipMonk\MemoryScanner\ObjectDeallocationChecker();
$objectDeallocationChecker->expectDeallocation($kernel, 'kernel');

$kernel->shutdown();
unset($kernel);

$memoryLeaks = $objectDeallocationChecker->checkDeallocations();

if (count($memoryLeaks) > 0) {
    Assert::fail($objectDeallocationChecker->explainLeaks($memoryLeaks));
}
```

Known Limitations
-----------------

[](#known-limitations)

- it's not possible to get list of registered shutdown handlers, so any leak caused by them will be unexplained
- xdebug in 'develop' mode sometimes leaks memory for unknown reasons, but notably 'debug' mode is fine

Installation:
-------------

[](#installation)

```
composer require shipmonk/memory-scanner
```

Contributing
------------

[](#contributing)

- Check your code by `composer check`
- Autofix coding-style by `composer fix:cs`
- All functionality must be tested

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance56

Moderate activity, may be stable

Popularity37

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity49

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

416d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5b545e3f9d982d538f11bc42b3dc2d186f706cef92c8bc8bc8f8788b08186ea5?d=identicon)[janedbal](/maintainers/janedbal)

![](https://www.gravatar.com/avatar/7a4170ebe9281cb76be91fe00f8eee307beb3e0744dfd40ba89d9c856372c7eb?d=identicon)[shipmonk](/maintainers/shipmonk)

---

Top Contributors

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

---

Tags

leakmemory

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/shipmonk-memory-scanner/health.svg)

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

###  Alternatives

[fjogeleit/prometheus-messenger-middleware

Prometheus Middleware for the Symfony Messenger Component

2255.2k](/packages/fjogeleit-prometheus-messenger-middleware)[spatie/craft-ray

Easily debug CraftCMS projects

1638.6k](/packages/spatie-craft-ray)

PHPackages © 2026

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