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)1510.5k↑13.5%2MITPHPPHP ^8.2CI passing

Since May 13Pushed 5mo 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 1mo ago

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 90% of packages

Maintenance61

Regular maintenance activity

Popularity33

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

370d 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

[symfony/stopwatch

Provides a way to profile code

2.8k387.2M918](/packages/symfony-stopwatch)[fruitcake/laravel-debugbar

PHP Debugbar integration for Laravel

19.1k662.9k29](/packages/fruitcake-laravel-debugbar)[spatie/ignition

A beautiful error page for PHP applications.

510147.6M69](/packages/spatie-ignition)[jokkedk/webgrind

Webgrind is a Xdebug profiling web frontend in PHP5. It implements a subset of the features of kcachegrind and installs in seconds and works on all platforms. For quick'n'dirty optimizations it does the job.

3.3k193.0k](/packages/jokkedk-webgrind)[koriym/printo

An object graph visualizer.

1421.8M2](/packages/koriym-printo)[soloterm/dumps

A Laravel command to intercept dumps from your Laravel application.

125285.7k3](/packages/soloterm-dumps)

PHPackages © 2026

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