Skip to content

Fix memory leak, issue 50486 #59239

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

Closed
wants to merge 0 commits into from
Closed

Fix memory leak, issue 50486 #59239

wants to merge 0 commits into from

Conversation

rch7
Copy link
Contributor

@rch7 rch7 commented Dec 17, 2024

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix 50486
License MIT

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.3 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@carsonbot
Copy link

Hey!

Oh no, it looks like you have made this PR towards a branch that is not maintained anymore. :/
Could you update the PR base branch to target one of these branches instead? 6.4, 7.1, 7.2, 7.3.

Cheers!

Carsonbot

@rch7 rch7 changed the base branch from 4.4 to 6.4 December 17, 2024 17:56
@rch7 rch7 requested review from xabbuh and yceruto as code owners December 17, 2024 17:56
Copy link
Member

@welcoMattic welcoMattic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide some metrics about the memory leak itself? A measurement before the fix and after would be helpful.

@@ -73,7 +73,6 @@ public function getValidTimezones(): iterable
yield ['EST5EDT'];
yield ['MST7MDT'];
yield ['PST8PDT'];
yield ['America/Montreal'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not seem to be related to the problem described in the issue. Can you revert this change?

@@ -1043,6 +1043,7 @@ public function testSubmitNullUsesDateEmptyData($widget, $emptyData, $expectedDa
$form = $this->factory->create(static::TESTED_TYPE, null, [
'widget' => $widget,
'empty_data' => $emptyData,
'years' => range(2018, (int) date('Y')),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not seem to be related to the problem described in the issue. Can you revert this change?

@@ -708,6 +708,7 @@ public function testSubmitNullUsesDateEmptyData($widget, $emptyData, $expectedDa
$form = $this->factory->create(static::TESTED_TYPE, null, [
'widget' => $widget,
'empty_data' => $emptyData,
'years' => range(2018, (int) date('Y')),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not seem to be related to the problem described in the issue. Can you revert this change?

@rch7 rch7 marked this pull request as draft December 18, 2024 01:14
@rch7 rch7 closed this Dec 18, 2024
@rch7 rch7 deleted the fix_50486 branch December 18, 2024 15:22
nicolas-grekas added a commit that referenced this pull request Jan 7, 2025
This PR was merged into the 6.4 branch.

Discussion
----------

[Mailer] Fix Sendmail memory leak

| Q             | A
| ------------- | ---
| Branch?       | 6.4 <!-- see below -->
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? |no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Issues        | Fix #50486 <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead -->
| License       | MIT

Previous PR: #59239

Fixes issue #50486 (Sendmail transport runs out of memory).
- I have removed unrelated changes that somehow got in the previous attempt of pull request because of wrong base version.
- As for the "metrics about the memory leak itself" - it is in the issue 50486. When write(), which is defined in vendor/symfony/mailer/Transport/Smtp/Stream/AbstractStream.php, is called without $debug parameter, it's true by default, and $this->debug gets appended all the email body data incrementally.
  So for example if you have loop sending personalized emails to 200,000 subscribers 20 kB each, $this->debug becomes 4 GB, plus overhead, and the script runs out of resources.
  The fix eliminates the problem.
<!--
Replace this notice by a description of your feature/bugfix.
This will help reviewers and should be a good start for the documentation.

Additionally (see https://symfony.com/releases):
 - Always add tests and ensure they pass.
 - 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 the latest branch.
 - For new features, provide some code snippets to help understand usage.
 - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry
 - Never break backward compatibility (see https://symfony.com/bc).
-->

Commits
-------

c74e2a3 fix_50486 - memory leak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants