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

Debugbar crashing application with out of memory exception #1511

Closed
DeveloperChris opened this issue Feb 12, 2024 · 3 comments
Closed

Debugbar crashing application with out of memory exception #1511

DeveloperChris opened this issue Feb 12, 2024 · 3 comments

Comments

@DeveloperChris
Copy link

DeveloperChris commented Feb 12, 2024

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.

@barryvdh
Copy link
Owner

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?

@barryvdh
Copy link
Owner

Can you try again with the latest version (and update your config). See #1512

@DeveloperChris
Copy link
Author

@barryvdh Amazing!

Such a rapid response and a successful solution. I pushed it to the max and it did not falter.

image

Truly impressed by your magic and the time you have devoted to this community.

Many Thanks

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

No branches or pull requests

2 participants