Skip to content

Commit 4e203f0

Browse files
andrew-dembnicolas-grekas
authored andcommitted
[HttpKernel] Avoid memory leaks cache attribute, profiler listener
1 parent b8cce26 commit 4e203f0

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
param('profiler_listener.only_main_requests'),
4040
])
4141
->tag('kernel.event_subscriber')
42+
->tag('kernel.reset', ['method' => '?reset'])
4243

4344
->set('console_profiler_listener', ConsoleProfilerListener::class)
4445
->args([

src/Symfony/Bundle/FrameworkBundle/Resources/config/web.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146

147147
->set('controller.cache_attribute_listener', CacheAttributeListener::class)
148148
->tag('kernel.event_subscriber')
149+
->tag('kernel.reset', ['method' => '?reset'])
149150

150151
->set('controller.helper', ControllerHelper::class)
151152
->tag('container.service_subscriber')

src/Symfony/Component/HttpKernel/EventListener/CacheAttributeListener.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,12 @@ public static function getSubscribedEvents(): array
182182
];
183183
}
184184

185+
public function reset(): void
186+
{
187+
$this->lastModified = new \SplObjectStorage();
188+
$this->etags = new \SplObjectStorage();
189+
}
190+
185191
private function getExpressionLanguage(): ExpressionLanguage
186192
{
187193
return $this->expressionLanguage ??= class_exists(ExpressionLanguage::class)

src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,14 @@ public function onKernelTerminate(TerminateEvent $event): void
129129
$this->profiler->saveProfile($this->profiles[$request]);
130130
}
131131

132+
$this->reset();
133+
}
134+
135+
public function reset(): void
136+
{
132137
$this->profiles = new \SplObjectStorage();
133138
$this->parents = new \SplObjectStorage();
139+
$this->exception = null;
134140
}
135141

136142
public static function getSubscribedEvents(): array

0 commit comments

Comments
 (0)