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

fix memory leak in production environments; #116

Merged
merged 2 commits into from
Oct 25, 2022

Conversation

CharlesBilbo
Copy link
Contributor

Currently, ignition logs information even when the APP_DEBUG is set to false this uses quite a bit of memory in production environments and can kill jobs that are doing bulk inserts in a look. I've added some logic and additional variables to determine when and when not to log in based on the environment and the APP_DEBUG var. I've also added the ability to turn off individual recorders.

Ive yet to add a unit test cause I'm not sure if yall will accept this implementation. if this is fine ill go ahead and write the testing for it.

@CharlesBilbo
Copy link
Contributor Author

@freekmurze Hey can I get some feedback on this.

@freekmurze
Copy link
Member

Hi, thanks for your work on this

The intention is good, but we think the implementation could be simplified.

Could you refactor this so the config file has a recorders array in which the class names of the recorders can be set?

'recorders' => [
    DumpRecorder::class,
    // all others...
];

Only the recorders in the config file should be executed.

Could you make this change?

@CharlesBilbo
Copy link
Contributor Author

Yes shouldn't be a problem.

@CharlesBilbo
Copy link
Contributor Author

@freekmurze Resolved the suggested changes.

@freekmurze
Copy link
Member

Very nice, thank you very much!

@freekmurze freekmurze merged commit c21309e into spatie:main Oct 25, 2022
@coffeeyoghurt
Copy link

@freekmurze / @CharlesBilbo sorry to hijack this PR. But is there a specific reason why the initial config setting should_record is removed from this PR? What is the suggested way to turn off the recorders in a specific environment now?

Like this?

'recorders' => env('APP_DEBUG', true) ? [
    DumpRecorder::class,
    JobRecorder::class,
    LogRecorder::class,
    QueryRecorder::class
] : [],

I'm experiencing a small memory leak when running tests in a project with spatie/laravel-ignition v1.64. Querying 100x a simple query via: \DB::table('some_table')->get() should not increase the memory on each loop but it does. Turning off all recorders solves the problem.

@CharlesBilbo
Copy link
Contributor Author

@coffeeyoghurt yes

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

Successfully merging this pull request may close these issues.

3 participants