Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Increment on Mass Data Logging Due to Ignition's LogRecorder when APP_DEBUG=FALSE #164

Open
Kristian4078 opened this issue Oct 9, 2023 · 3 comments
Assignees

Comments

@Kristian4078
Copy link

Kristian4078 commented Oct 9, 2023

When logging a significant amount of data in a single request, I observed a consistent increase in memory usage. This increment persisted even after logging my message and explicitly clearing it from memory.

Upon further investigation, I found that the culprit is Spatie\LaravelIgnition\Recorders\LogRecorder. It continuously stores all logged messages within the $this->logMessages[] property, regardless of whether the Laravel application's APP_DEBUG is set to FALSE.

In a non-debug environment, one would expect that these Exception interfaces aren't thrown, and thus, Ignition should not execute. However, this behavior persists even when the application is not in debug mode. Furthermore, setting enable_runnable_solutions to FALSE did not resolve the issue.

To circumvent this behavior, which I perceive as a memory leak in production, I've adjusted my Ignition configuration as follows:

$config = [ /* ... original configuration ... */];

if (env('APP_DEBUG', false) == false) {
    $config['recorders'] = [];
    $config['argument_reducers'] = [];
    $config['solution_providers'] = [];
    $config['with_stack_frame_arguments'] = false;
    $config['enable_runnable_solutions'] = false;
}

return $config;

This temporary fix ensures efficient memory usage in production, as we don't want unnecessary memory consumption when we aren't debugging or displaying Ignition messages.

I believe it would be beneficial for the package to address this behavior, ensuring that memory isn't wastefully used in production environments.

@dusanbre
Copy link

dusanbre commented Dec 1, 2023

Yes, I had the same problem, the only difference is that I used a Bulk insert. There is an event in the library that logs all queries in memory. Please fix this.

@MaartenWaegeman
Copy link

I'm having similar issues, where I have a job that needs to insert 1M+ records and it fails due to running out of memory.

@timvandijck timvandijck self-assigned this Apr 29, 2024
@slakbal
Copy link

slakbal commented May 15, 2024

@freekmurze @timvandijck I have the same issue here. I'm doing bulk inserts of mass data using a generator and DB:insert(). Ignition is eating up the memory. Once I removed it from composer.json memory stayed stable. Maybe an easy solution is to be able to disable ignition at runtime... ie. Ignition:disable() so that it can be disabled for the request life-cycle, or a queued job, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants