I've encountered a significant issue with the laravel-n-plus-one-detector package related to memory usage. When using this package in my Laravel application, I'm experiencing PHP fatal errors due to exhausted memory limits. Below are the error logs:
2024/11/21 14:21:52 [error] 1876#1876: *58 FastCGI sent in stderr: "PHP message: PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 262144 bytes) in /var/www/xxx/vendor
2024/11/21 14:21:57 [error] 1876#1876: *60 FastCGI sent in stderr: "PHP message: PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 16384 bytes) in /var/www/xxx/vendor
2024/11/21 14:23:04 [error] 2113#2113: *1 FastCGI sent in stderr: "PHP message: PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 262144 bytes) in /var/www/xxx/vendor
I have a memory limit of 1GB set in my php.ini file, but the application still exceeds this limit when the laravel-n-plus-one-detector package is active. Interestingly, when I remove this package, the memory issues disappear, indicating that the package itself is causing the high memory usage.
Here are some additional details about my setup:
Laravel Version: [Laravel 11.x]
PHP Version: [8.3 FPM]
Database: MySQL
Web Server: Nginx
Steps to Reproduce:
Install the laravel-n-plus-one-detector package.
Use the package to detect N+1 queries in a Laravel application.
Monitor the memory usage and observe the PHP fatal errors due to memory exhaustion.
Expected Behavior: The package should efficiently detect N+1 queries without causing excessive memory usage and PHP fatal errors.
Actual Behavior: The package causes excessive memory usage, leading to PHP fatal errors and memory exhaustion.
Temporary Solution: Removing the laravel-n-plus-one-detector package resolves the memory issues, but this is not a viable long-term solution as it negates the benefits of using the package for N+1 query detection.
Additional Context: I believe the issue might be related to how the package processes and stores query data, leading to high memory consumption. Any guidance on optimizing memory usage or potential fixes would be greatly appreciated.
Thank you for your attention to this matter. I look forward to your response and any potential solutions.
Best regards
I've encountered a significant issue with the laravel-n-plus-one-detector package related to memory usage. When using this package in my Laravel application, I'm experiencing PHP fatal errors due to exhausted memory limits. Below are the error logs:
I have a memory limit of 1GB set in my php.ini file, but the application still exceeds this limit when the laravel-n-plus-one-detector package is active. Interestingly, when I remove this package, the memory issues disappear, indicating that the package itself is causing the high memory usage.
Here are some additional details about my setup:
Steps to Reproduce:
Install the laravel-n-plus-one-detector package.
Use the package to detect N+1 queries in a Laravel application.
Monitor the memory usage and observe the PHP fatal errors due to memory exhaustion.
Expected Behavior: The package should efficiently detect N+1 queries without causing excessive memory usage and PHP fatal errors.
Actual Behavior: The package causes excessive memory usage, leading to PHP fatal errors and memory exhaustion.
Temporary Solution: Removing the laravel-n-plus-one-detector package resolves the memory issues, but this is not a viable long-term solution as it negates the benefits of using the package for N+1 query detection.
Additional Context: I believe the issue might be related to how the package processes and stores query data, leading to high memory consumption. Any guidance on optimizing memory usage or potential fixes would be greatly appreciated.
Thank you for your attention to this matter. I look forward to your response and any potential solutions.
Best regards