Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Memory Laravel Package

tkachikov/memory

tkachikov/memory is a lightweight Laravel/PHP package that provides memory-focused helpers for inspecting and working with memory usage in your application. It gives developers a simple way to add memory diagnostics and monitoring to Laravel projects.

Deep Wiki
Context7

At a glance

Frequently asked questions about Memory
How do I install tkachikov/memory with Composer?
Install it with composer require tkachikov/memory in the root of your Laravel project. Laravel package auto-discovery will register the service provider and facade, so no manual registration is normally required. If the package ships a config file, publish it with the vendor:publish command so you can adjust output units. Commit the composer.json and composer.lock changes so other environments get the same version.
Which Laravel versions does tkachikov/memory support?
The package is described as a lightweight Laravel/PHP helper library built on native PHP memory functions, so it has very little framework surface to break. The listed overview does not pin specific Laravel versions, so check the composer.json require constraints for illuminate/support and php before adopting it in a fixed-version project. If you are on an older or pre-release Laravel version, run the test suite or a quick smoke check in a branch first.
How do I read current memory versus peak memory usage?
The package exposes helpers that read current, peak and real memory usage at the moment you call them, so you can place calls at any point in the request lifecycle. Current usage reflects memory allocated to PHP right now, peak reflects the highest value reached so far, and real usage reflects memory reserved from the operating system. Calling the helpers before and after a suspected heavy operation gives you a fast delta measurement.
Can I log memory snapshots to compare checkpoints in a request?
Yes, the package supports logging memory snapshots so you can compare checkpoints across a request or job. Add a snapshot before and after heavy work such as large queries or collection transformations, then compare the recorded values to isolate the expensive step. This is usually more useful than a single reading because it shows growth rather than absolute totals.
How do I change the memory output from bytes to KB or MB?
Output units are configurable, and the package supports bytes, KB and MB. Set the preferred unit in the package configuration so helper and facade output is already formatted for logs and dashboards. Keeping one unit across the codebase avoids confusion when comparing snapshots recorded in different places.
What is the performance overhead of leaving memory tracking enabled?
The package is described as having minimal overhead because it relies on native PHP memory functions rather than instrumentation layers. It is safe to leave enabled in development and staging, which is where you will get the most value from snapshots. In production, keep logging selective and behind a config or environment flag so you do not flood your log storage with per-request entries.
How can I use it to detect memory leaks in queued jobs?
Take a snapshot at the start and end of each job, and log the delta or peak value for every iteration of a batch or worker loop. A steadily climbing peak across iterations points to retained references, growing static caches or unflushed collections. Combining the snapshot data with your queue worker memory limits helps you decide when to restart workers or refactor the job.
Does tkachikov/memory work outside of Laravel in plain PHP?
The package is presented as a Laravel/PHP library, and the values it reads come from standard PHP functions such as memory_get_usage and memory_get_peak_usage. That means the underlying helpers are conceptually usable in plain PHP scripts, while the facade and helper API assume a Laravel container is bootstrapped. For non-Laravel projects, verify the service provider is not required before relying on it.
How do I test memory behaviour in my Laravel test suite?
Call the helpers or facade in a feature test around the code path you care about and assert on the resulting snapshot values or logged output. Remember that PHP and PHPUnit hold their own allocations, so absolute numbers vary between machines; assert on direction and rough thresholds rather than exact bytes. If you test peak behaviour, run it in an isolated process, since peak memory is never reset within a single PHP process.
What alternatives exist for monitoring memory in Laravel?
Laravel Telescope, Laravel Debugbar and Ray-style debugging tools all surface memory figures alongside queries and requests, and Symfony Stopwatch can time and measure memory around blocks of code. Native calls to memory_get_usage and memory_get_peak_usage are the zero-dependency fallback. tkachikov/memory is a good fit when you want a small, focused helper API and snapshot logging without pulling in a full debugging dashboard.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
abbasudo/artisan-route
mirvan/ippanel
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package