Skip to content

LeaklessZero-State & Memory Leak Prevention

The autonomous runtime guardian and static analysis engine for persistent PHP workers (FrankenPHP, RoadRunner, Swoole, Symfony, Laravel & Vanilla).

Quick Installation ​

bash
composer require themattosdev/leakless
bash
composer require --dev themattosdev/leakless-dev

Worker Protection Example ​

ini
LEAKLESS_ENABLED=true
LEAKLESS_MAX_DRIFT_MB=64
LEAKLESS_CHECK_TRANSACTIONS=true
LEAKLESS_CHECK_FILE_DESCRIPTORS=false
php
use TheMattos\Leakless\DTOs\Config;
use TheMattos\Leakless\Integrations\FrankenPhp\FrankenPhp;

FrankenPhp::run(
    app: fn () => print(json_encode(['status' => 'ok'])),
    config: new Config(
        maxDriftMb: 64,
        checkTransactions: true,
        resettables: [
            App\Services\CartSession::class,
            fn () => LegacyStatic::$cache = [],
        ],
    ),
);
php
test('orders endpoint executes cleanly without state or memory drift', function () {
    // 1. Structural reflection check
    expect(PaymentGateway::class)->toBeLeakless();

    // 2. Request lifecycle & Kernel RSS drift check
    expect(function () {
        (new ProcessInvoicesJob())->handle();
    })->toRunCleanly(maxDriftMb: 0.25);

    // 3. Container singletons state mutation snapshot
    expect(app())->toResetContainerState(function () {
        $this->postJson('/api/checkout', ['plan' => 'pro']);
    });
});
bash
vendor/bin/leakless analyze

Released under the MIT License.