Skip to content

call gc_collect_cycles() for every message#2168

Merged
blued-gear merged 4 commits into
mainfrom
fix/gc_in_messengers
Jul 19, 2026
Merged

call gc_collect_cycles() for every message#2168
blued-gear merged 4 commits into
mainfrom
fix/gc_in_messengers

Conversation

@blued-gear

Copy link
Copy Markdown
Collaborator

This might help keeping the memory-consumption of the messengers low. It might also not help, but the worst it can do is add a few milliseconds of delay to the processing of every message.

As far as I checked it helped on some message type and on others it did not lower the overall memory consumption. If this is worth merging is up to you.

*/
public function workWrapper(MessageInterface $message): void
{
gc_collect_cycles();

@BentiGorlich BentiGorlich Jul 18, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

wouldn't this make more sense to be called at the end? So after a message has been processed

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It would.
But if something goes very wrong, it might not reach this statement. As there are almost always new messages it should not make much of a difference.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That's the use case for finally ;)

@blued-gear
blued-gear enabled auto-merge (squash) July 19, 2026 10:53
@blued-gear
blued-gear merged commit f0520d2 into main Jul 19, 2026
9 checks passed
@blued-gear
blued-gear deleted the fix/gc_in_messengers branch July 19, 2026 10:54
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.

3 participants