-
Notifications
You must be signed in to change notification settings - Fork 647
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
[4.5.15]: Delayed logging and high memory usage in Console Controller #14242
Comments
@romainpoirier are you able to privately share the URL, so I can reproduce exactly what you're seeing? You can share with me on Discord (timkelty) or to [email protected]. Also, could you share your composer.json, composer.lock, and |
There's no URL to share as this Controller is run from the console. |
I mean the URL you're passing to the console command, that has the element API response. |
I'm not able to share you the URL as it's a protected URL. However, here's the content of the first page (with fake data for testing purpose):
|
@romainpoirier a couple things to try: Within your loop, add:
I suspect this will help with the memory consumption. Also, instead of replacing
|
@romainpoirier Just following up – were you able to test any of that? |
Closing, but let me know if you're still having issues. |
Sorry for the late reply, I'm was very busy working on this project. |
@romainpoirier Craft's default loggers use Monolog log targets, so either way you're using Monolog. |
Description
I'm experiencing issues with delayed logging and high memory usage in a Craft CMS console controller. The issue arises while handling a large feed with over 40,000 elements, segmented into pages of 5 elements each. The logs are only written after the entire script execution is complete, leading to inaccurate timestamps and excessive memory consumption. In cases where the script is abruptly stopped, no logs are recorded.
Steps to Reproduce
4.5.15
.do { while }
for pagination andforeach
for processing the data.Expected Behavior
I expected the logs to be written immediately or at more frequent intervals for accurate timestamping. Additionally, the memory usage should be optimized to handle the high volume of data without causing controller crashes.
Actual Behavior
The actual behavior observed was a significant delay in log writing, resulting in inaccurate timestamps. If the script execution was interrupted, no logs were recorded at all. When processing the large volume of elements, the high memory usage led to crashes of the controller.
Question
I'm aware of the
reset()
function in Monolog, for handling long-running processes and avoiding memory leaks (Monolog documentation), that maybe could help. Is there a similar functionality available in Craft CMS that can help in managing log writing more effectively?Code Sample
Craft CMS version
4.5.15
PHP version
8.1.13
The text was updated successfully, but these errors were encountered: