PHPackages                             webparking/laravel-queue-garbage-collection - 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. [Queues &amp; Workers](/categories/queues)
4. /
5. webparking/laravel-queue-garbage-collection

ActiveLibrary[Queues &amp; Workers](/categories/queues)

webparking/laravel-queue-garbage-collection
===========================================

Collect PHP reference cycles after every queue job to keep long-running workers from leaking off-heap memory.

v1.0.0(1mo ago)0389—8.6%MITPHP ^8.1

Since Jul 6Compare

[ Source](https://github.com/webparking/laravel-queue-garbage-collection)[ Packagist](https://packagist.org/packages/webparking/laravel-queue-garbage-collection)[ RSS](/packages/webparking-laravel-queue-garbage-collection/feed)WikiDiscussions Synced 1w ago

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

Collect garbage cycles after every queue job
============================================

[](#collect-garbage-cycles-after-every-queue-job)

[![Latest Version on Packagist](https://camo.githubusercontent.com/1b64031efdb957671a6423942b29a3953e01c904baa887ff46153bb89f52c982/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7765627061726b696e672f6c61726176656c2d71756575652d676172626167652d636f6c6c656374696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/webparking/laravel-queue-garbage-collection)[![Total Downloads](https://camo.githubusercontent.com/3de269e6fd9e78dae30408ff724b7d0134a627d9e9b134fb9ee27ac5e437bf50/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7765627061726b696e672f6c61726176656c2d71756575652d676172626167652d636f6c6c656374696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/webparking/laravel-queue-garbage-collection)[![run-tests](https://github.com/webparking/laravel-queue-garbage-collection/actions/workflows/run-tests.yml/badge.svg)](https://github.com/webparking/laravel-queue-garbage-collection/actions/workflows/run-tests.yml)

A zero-config Laravel package that runs `gc_collect_cycles()` after every queue job.

Why this exists
---------------

[](#why-this-exists)

Long-running queue workers accumulate PHP reference cycles that pin **off-heap** memory: the native buffers behind libcurl and OpenSSL (any HTTP client or SDK), DOM trees, image resources, and similar extension-backed objects. That memory is invisible to `memory_get_usage()`, so `queue:work --memory` never trips on it. Meanwhile PHP's adaptive cyclic garbage collector backs off precisely in this situation — the cycles hold only a handful of PHP objects while pinning a lot of native memory, so the collector's object-count heuristic sees nothing worth collecting. The result: resident memory (RSS) climbs job after job until the worker is OOM-killed.

Forcing a collection at each job boundary releases those cycles immediately and keeps memory flat. It is safe to force per job because queue workers share no state between jobs, so nothing you'd want to keep is ever collected.

Installation
------------

[](#installation)

```
composer require webparking/laravel-queue-garbage-collection
```

That's it. The service provider auto-registers via Laravel's package discovery and hooks a listener onto both `JobProcessed` (success) and `JobExceptionOccurred` (each failed attempt). The listener calls `gc_collect_cycles()` and nothing else.

When you might not want it
--------------------------

[](#when-you-might-not-want-it)

The only profile where this is pure overhead is a very high-throughput queue of tiny, cycle-free jobs under no memory pressure — there, each collection scans the GC root buffer and frees nothing. Everywhere else the cost is negligible, and it is never a correctness risk (workers share no state across jobs, so a forced collection can only reclaim genuine garbage).

Supported versions
------------------

[](#supported-versions)

Every combination below is exercised in CI:

PHPLaravelTestbench8.1978.21088.31198.412108.51311Testing &amp; local development
-------------------------------

[](#testing--local-development)

The full PHP × Laravel matrix runs locally via [`act`](https://nektosact.com), executing the exact CI workflow in Docker:

```
make test               # run the whole matrix (needs `act` + Docker)
make test-job php=8.3   # run a single PHP version from the matrix
```

For day-to-day work there's a Docker workspace pinned to the newest supported combination (PHP 8.5 / Laravel 13):

```
make start     # start the workspace and install dependencies
make phpunit   # run the test suite once
make phpstan   # run static analysis
make cs-fix    # apply code style
make help      # list all targets
```

Prefer running things yourself? `composer install && composer test` works too.

License
-------

[](#license)

The MIT License (MIT). Please see the [License File](LICENSE.md) for more information.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance90

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

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

48d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15359366?v=4)[Webparking BV](/maintainers/webparking)[@webparking](https://github.com/webparking)

---

Tags

laravelmemoryqueuegcgarbage collection

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/webparking-laravel-queue-garbage-collection/health.svg)

```
[![Health](https://phpackages.com/badges/webparking-laravel-queue-garbage-collection/health.svg)](https://phpackages.com/packages/webparking-laravel-queue-garbage-collection)
```

###  Alternatives

[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.2k99.8M359](/packages/laravel-horizon)[laravel/scout

Laravel Scout provides a driver based solution to searching your Eloquent models.

1.7k57.2M686](/packages/laravel-scout)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

46273.9k](/packages/harris21-laravel-fuse)[fomvasss/laravel-ai-tasks

AI task orchestrator for Laravel: routing, queue, audit, budget, webhooks

381.6k1](/packages/fomvasss-laravel-ai-tasks)[anousss007/vigilance

A driver-agnostic control center for Laravel queues, jobs, commands and the scheduler. Monitor what ran (with parameters), see failures, and dispatch jobs or run artisan commands manually from a self-contained dashboard.

1949.9k](/packages/anousss007-vigilance)[yangusik/laravel-balanced-queue

Laravel queue management with load balancing between partitions (user groups)

8516.9k](/packages/yangusik-laravel-balanced-queue)

PHPackages © 2026

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