-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[EventDispatcher] Add tag kernel.rest on 'debug.event_dispatcher' service #32421
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This PR was merged into the 3.4 branch. Discussion ---------- [Console] Update inherit and add licence | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | none <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | not needed <!-- required for new features --> <!-- Replace this notice by a short README for your feature/bugfix. This will help people understand your PR and can be used as a start for the documentation. Additionally (see https://symfony.com/roadmap): - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against branch 4.4. - Legacy code removals go to the master branch. --> see https://github.com/symfony/symfony/pull/32318/files#r299561556 it needs to be updated in the lowest branch. Commits ------- ff0c141 [Console] Update to inherit and add licence
nicolas-grekas
approved these changes
Jul 8, 2019
fabpot
approved these changes
Jul 8, 2019
Let's merge in 3.4. Leaking memory is a bug. |
0814b07
to
5249eaf
Compare
Thank you @lyrixx. |
fabpot
added a commit
that referenced
this pull request
Jul 8, 2019
…atcher' service (lyrixx) This PR was submitted for the 4.4 branch but it was merged into the 3.4 branch instead (closes #32421). Discussion ---------- [EventDispatcher] Add tag kernel.rest on 'debug.event_dispatcher' service | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | In CLI, Symfony leaks because it uses the TraceableEventDispatcher. Let's make this service resetable. This PR is related to #32418 --- Side note: Forcing user to use the `ServicesResetter` is IMHO bad for the DX. I prefer to have something that does not leak by default. More over, the TraceableEventDispatcher stores some informations for the profiler. But in CLI it does not make sens, since the tooling does not exist. I have already fixed such issue for monolog in #30339. I think we should do the same for the TraceableEventDispatcher. --- Note: When using #32418 + this PR and with the following code, it does not leak **at all** <details> <summary>code</summary> ```php <?php namespace App\Command; use Psr\Log\LoggerInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\EventDispatcher\Event; use Symfony\Component\HttpKernel\DependencyInjection\ServicesResetter; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; class LeakCommand extends Command { protected static $defaultName = 'leak'; private $dispatcher; private $resetter; private $logger; public function __construct(EventDispatcherInterface $dispatcher, ServicesResetter $resetter, LoggerInterface $logger) { $this->dispatcher = $dispatcher; $this->resetter = $resetter; $this->logger = $logger; parent::__construct(); } protected function execute(InputInterface $input, OutputInterface $output) { $this->dispatcher->addListener(MyEvent::class, function ($e) { }); for ($i=0; $i < INF; $i++) { $output->writeln(memory_get_usage()); $this->dispatcher->dispatch(new MyEvent()); $this->logger->debug('some log'); // if ($i > 2000) { // meminfo_dump(fopen('/tmp/my_dump_file.json', 'w')); // die; // } usleep(100); $this->resetter->reset(); } } } class MyEvent {} ``` </detail> Commits ------- 5249eaf [EventDispatcher] Add tag kernel.rest on 'debug.event_dispatcher' service
What do you think about my comment to remove it in cli env ? |
@lyrixx I think it makes sense. |
This was referenced Jul 8, 2019
This was referenced Jul 27, 2019
Merged
Merged
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In CLI, Symfony leaks because it uses the TraceableEventDispatcher.
Let's make this service resetable.
This PR is related to #32418
Side note: Forcing user to use the
ServicesResetter
is IMHO bad forthe DX. I prefer to have something that does not leak by default.
More over, the TraceableEventDispatcher stores some informations for the
profiler. But in CLI it does not make sens, since the tooling does not
exist. I have already fixed such issue for monolog in #30339. I think we
should do the same for the TraceableEventDispatcher.
Note: When using #32418 + this PR and with the following code, it does not leak at all
code