Skip to content

LeaklessPrevenção de Estado & Vazamento de Memória

Motor de runtime autônomo e análise estática para workers persistentes em PHP (FrankenPHP, RoadRunner, Swoole, Symfony, Laravel e Vanilla).

Instalação Rápida ​

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

Exemplo de Proteção de Worker ​

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('endpoint de pedidos executa de forma limpa sem vazamentos', function () {
    // 1. Checagem de reflexão estrutural
    expect(PaymentGateway::class)->toBeLeakless();

    // 2. Checagem de ciclo de requisição e drift de RSS
    expect(function () {
        (new ProcessInvoicesJob())->handle();
    })->toRunCleanly(maxDriftMb: 0.25);

    // 3. Snapshot de mutações de estado em singletons do container
    expect(app())->toResetContainerState(function () {
        $this->postJson('/api/checkout', ['plan' => 'pro']);
    });
});
bash
vendor/bin/leakless analyze

Released under the MIT License.