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
[TwigComponent] out of memory #1776
Comments
How many times do you loop? |
It's a double loop. In my case I'm starting to have memory issue when displaying a table with > 100 rows and about 10 Columns. I wanted to use components as macros replacements as it's a lot cleaner and I really like how components are working. |
What type of component are you using ? Anonymous ? Twig ? Or Live ? Could you share a bit of the component code, maybe we can suggest you some ideas to lower the memory. Is this also the case in production ? The profiler can cause a lot of memory usage in dev |
Thanks for reactivity. I'm using both anonymous and non anonymous components. But no live components Here is an example when using an anonymous component to display a cell.
But if I include the code directly it's working fine with same amount of memory. I didn't even have to change sub components usage, but I assume this could result in even bigger memory usage improvements.
The component itself set a bunch of variables then call other components.
|
By replacing almost all sub components (7 out of 8) I was able to halves memory consumption (from 200M to 100M) |
Just by curiosity could you share the "overall" content of your deepest components ? twig:Episodes:ProductionTable:Partials:TdStartOfWorkflow twig:Episodes:ProductionTable:Partials:TdEndOfWorkflow ? But i can already answer: you won't ever compete with includes in that configuration, as Component do a lot more things and are renderered each one in an isolated context (leading to many duplication of vars). |
Most of those components are really simple ones rendering some twig like this one:
I do understand that components add extra cpu/memory usage, but after rendering shouldn't the memory be freed before rendering other components ? |
It's like all components stays in memory until the whole file is rendered. |
It's hard to say without seeing more... 😅 If you have some time to investigate a bit and make some discoveries there, i'd be really happy to ear them and see what we could improve ! |
I've tried quite a lots of thinks, without much success. By the way flush does not work inside twig component. Which seems quite logic, but it would be great to be able to make streamable components too. If you have any idea I could test in my workspace I would be glad to try. Thanks for you time |
@choarau-craft would you agree to share here (or privately if you prefer) a capture of the full twig component profiler page ? (let's say for a render with 100-ish components) ? |
Hi, I won't have time this week, but will be available next week. |
You can find me on the Symfony Slack channel, or send me an email at |
Hello,
I've started to refactor a qui big application using twig components, but recently I ran into out of memories.
When I'm on the breach, I tried several things to find out what could cause those.
Replacing a simple twig component (without php file) by it's content fixed the memory issue when that component is called about a thousand of time in a loop.
So it's seems like components are adding a lot of memory consumption when used in loops.
Is that the expected behavior, is there any way to fix this ?
Thanks a lot
The text was updated successfully, but these errors were encountered: