bugsnag / bugsnag-laravel

BugSnag notifier for the Laravel PHP framework. Monitor and report Laravel errors.
https://docs.bugsnag.com/platforms/php/laravel/
MIT License
876 stars 129 forks source link

[2.x] Uses `NullableShutdownStrategy` on tests #493

Open nunomaduro opened 2 years ago

nunomaduro commented 2 years ago

This pull request fixes a memory leak of this package with Laravel's unit tests, where the Illuminate\Foundation\Application instance is being leaked to PHP's internal shutdown function.

In other words, Laravel often creates application instances during tests, and bugsnag is registering (for each new test case) a new shutdown function with those application instances.

With this fix, we're able to decrease the memory usage of a 600 test suite by 14% percent:

Tests: 600
Before: 190.50 MB
After: 168.50 MB

Note, #65 equally needs to merged and tagged.

luke-belton commented 2 years ago

Hi @nunomaduro - could you explain a bit more about your use case here please? 600 tests sound like a lot to have a direct dependency on Bugsnag. Is there no way for you to isolate those tests from Bugsnag and/or mock Bugsnag to avoid that dependency?

johnkiely1 commented 1 year ago

Hi @nunomaduro, have you seen the message from luke-belton above? We would really need to understand your use case in order to consider this PR.

Gavrisimo commented 1 year ago

@luke-belton @johnkiely1 I think this originated in this issue: https://github.com/laravel/framework/issues/44214

johnkiely1 commented 1 year ago

We will look to review this PR when priorities allow.