Skip to content

Commit 44ce4dd

Browse files
committed
bug symfony#27923 [Form/Profiler] Massively reducing memory footprint of form profiling pages... (VincentChalnot)
This PR was merged into the 3.4 branch. Discussion ---------- [Form/Profiler] Massively reducing memory footprint of form profiling pages... … by removing redundant 'form' variable from view variables. | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | ## Problem When trying to profile large forms in web profiler, the page can get so big that the memory footprint of the web browser excedes 1Gb making everything unusable and sometimes crashing the browser. This is especially true for "deep" forms as every node of the form also contains its children in the debugging infos. ## Solution When removing the "form" view variable that actually contains duplicated contents of everything already displayed in the page, the memory footprint massively decrease making the page usable again even form very complex and deep forms. By using CutStub, we keep a necessary level of information by providing the information that the variable is indeed here but not directly accessible in the dump. Commits ------- 5f5077f [Form/Profiler] Massively reducing memory footprint of form profiling pages by removing redundant 'form' variable from view variables.
2 parents 137753d + 5f5077f commit 44ce4dd

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Symfony/Component/Form/Extension/DataCollector/FormDataExtractor.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Form\FormView;
1616
use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter;
1717
use Symfony\Component\Validator\ConstraintViolationInterface;
18+
use Symfony\Component\VarDumper\Caster\CutStub;
1819

1920
/**
2021
* Default implementation of {@link FormDataExtractorInterface}.
@@ -155,6 +156,10 @@ public function extractViewVariables(FormView $view)
155156
);
156157

157158
foreach ($view->vars as $varName => $value) {
159+
// Removing redundant variable from view variables
160+
if ('form' === $varName) {
161+
$value = new CutStub($value);
162+
}
158163
$data['view_vars'][$varName] = $value;
159164
}
160165

0 commit comments

Comments
 (0)