Skip to content

Release the parent's reference in MimeMessage::remove() - #76

Closed
iliaal wants to merge 1 commit into
php:masterfrom
iliaal:fix-mimemessage-remove-leak
Closed

iliaal wants to merge 1 commit into
php:masterfrom
iliaal:fix-mimemessage-remove-leak

Conversation

@iliaal

@iliaal iliaal commented Oct 31, 2026

Copy link
Copy Markdown
Member

MimeMessage::remove() deleted the child's entry from the parent's children table, which has no destructor, without dropping the reference the entry held, so every removed part stayed allocated until the end of the request. A loop that parses a message and removes a part grows without bound in a long-running worker (about 1.7 KB per iteration for a message with a 1 KB part). Depends on #75, which makes it safe for a removed part to be freed; only the last commit is new here.

@iliaal
iliaal requested a review from remicollet October 31, 2026 15:37
@remicollet

Copy link
Copy Markdown
Member

Please rebase after #75

@remicollet

Copy link
Copy Markdown
Member

Feel free to open a single PR with the 3 commits, if simpler for you

php_mimepart_remove_from_parent() deleted the child's entry from the
parent's children table, which has no destructor, without dropping the
reference that entry held. A removed part therefore stayed allocated until
the end of the request, so a loop that builds a message and removes a part
grows memory without bound in a long-running process.
@iliaal
iliaal force-pushed the fix-mimemessage-remove-leak branch from 849fcfa to 32d09d0 Compare November 6, 2026 13:20
@iliaal

iliaal commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

Rebased

@remicollet

Copy link
Copy Markdown
Member

Thanks,
Merged

@remicollet remicollet closed this Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants