Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Fix memory leak for worker fallbehind timers #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

perilsensitive
Copy link

This is a quick fix for a memory leak that I noticed by comparing heapdumps. If you think a different fix is more appropriate, please feel free to implement something else.

Anyway, when a worker dies, the worker object in the master process never gets garbage collected because the fall-behind timer object still holds a reference to it. Since the callback to setTimeout calls measureFallBehind() and sets up a new timeout again, the timer is never cleaned up either.

This patch modifies the callback to setTimeout so that it only calls that.measureFallBehind() if the worker isn't dead, preventing the timer from being set up again and allowing the Timer and Worker objects to be garbage collected.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 75.604% when pulling e7cf1ea on perilsensitive:timer_memory_leak into d86329b on pipedrive:master.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants