You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was chasing down a difficult memory exception issue with an application that performs hundreds if not thousands of queries to display a page.
The below is an explanation of why I am at this point for those who will undoubtedly offer me pointers on better ways to do it...
Although I should be paginating and soon will be, this application is a Proof of concept to replace a 20 year old Perl program which has not been supported for the last 8 years.
My challenge is to first replicate the existing application as close as possible, and then offer solutions.
All was going swimmingly until I ran one of the more complex queries which outputted a tree of information.
Rather than write a large number of different queries I chose to use relationships and nested blade templates. This is far easier to implement, but perhaps not the most memory efficient.
Each template displays its data and then any child data. The maximum depth of a tree node is 5 levels so very shallow as trees go.
After running my query it crashed with an OOM exception at 128MB.
To help resolve the issue as I have an upcoming demo, I bumped up the amount of RAM available to 256MB and ran the process again
It got worse, significantly worse, now it was simply white screening with the browser loading icon spinning away endlessly.
Following a hunch I decided to disable debugbar.
All memory issues went away.
I added instrumentation to report memory usage after every iteration of the nested blade templates. At its peak all I could see that the script was using was around 35MB. after growing only 10MB from the initial size at the start of output.
I assume debugbar was consuming all the remaining memory as it was the only change made from not working to working.
Happy to help where I can to resolve this issue. I cannot provide any source code but will provide snippets if possible. The actual code cannot be made public.
Note: I do not use Octane and this is running a plain install of Laravel 10 uses an un modified php-fpm docker container with nginx container as the reverse proxy and mariadb container as the database.
The text was updated successfully, but these errors were encountered:
Well if you're displaying thousands of queries, that would be quite some impact yes.. Not sure what to do about that, except maybe I can limit the number of queries?
I was chasing down a difficult memory exception issue with an application that performs hundreds if not thousands of queries to display a page.
The below is an explanation of why I am at this point for those who will undoubtedly offer me pointers on better ways to do it...
Although I should be paginating and soon will be, this application is a Proof of concept to replace a 20 year old Perl program which has not been supported for the last 8 years.
My challenge is to first replicate the existing application as close as possible, and then offer solutions.
All was going swimmingly until I ran one of the more complex queries which outputted a tree of information.
Rather than write a large number of different queries I chose to use relationships and nested blade templates. This is far easier to implement, but perhaps not the most memory efficient.
Each template displays its data and then any child data. The maximum depth of a tree node is 5 levels so very shallow as trees go.
After running my query it crashed with an OOM exception at 128MB.
To help resolve the issue as I have an upcoming demo, I bumped up the amount of RAM available to 256MB and ran the process again
It got worse, significantly worse, now it was simply white screening with the browser loading icon spinning away endlessly.
Following a hunch I decided to disable debugbar.
All memory issues went away.
I added instrumentation to report memory usage after every iteration of the nested blade templates. At its peak all I could see that the script was using was around 35MB. after growing only 10MB from the initial size at the start of output.
I assume debugbar was consuming all the remaining memory as it was the only change made from not working to working.
Happy to help where I can to resolve this issue. I cannot provide any source code but will provide snippets if possible. The actual code cannot be made public.
Note: I do not use Octane and this is running a plain install of Laravel 10 uses an un modified php-fpm docker container with nginx container as the reverse proxy and mariadb container as the database.
The text was updated successfully, but these errors were encountered: