Skip to content

Fix memory leak: remove pager listeners once the pager is persisted - #1999

Open
guillaume-sainthillier wants to merge 1 commit into
FriendsOfSymfony:masterfrom
guillaume-sainthillier:fix/register-listeners-memory-leak
Open

guillaume-sainthillier wants to merge 1 commit into
FriendsOfSymfony:masterfrom
guillaume-sainthillier:fix/register-listeners-memory-leak

Conversation

@guillaume-sainthillier

Copy link
Copy Markdown
Contributor

RegisterListenersService adds listeners to the shared dispatcher for every pager and never removes them. With --pager-persister=async, the Messenger worker provides a new pager per AsyncPersistPage message, so each listener keeps its pager (and the objects of its current page) alive.

On a 2.15M-document index with --max-per-page=5000, the worker grew by ~80 MB per page and hit a 2 GB memory_limit after 22 pages.

The listeners are now removed on the pager's PostPersistEvent.

RegisterListenersService added listeners to the shared dispatcher for
every pager and never removed them. A Messenger worker handling
AsyncPersistPage messages provides a new pager with each message, so
every page stayed referenced, with its objects, until the worker ran
out of memory.
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.

1 participant