Skip to content

Buffer is leaking a thread every time it's full #99

Closed
@fbernier

Description

I recently deployed an update of this gem and immediately noticed the thread count per instance was constantly increasing over time.

Here's what it looked like:
image

After looking into the code, I found the cause.

When the buffer is initialized, it calls reset_buffer to set up the buffer state. In there, it launches a timer thread containing an infinite loop.

on buffer_receive, the default behaviour when the buffer is full is to drop the messages. It does so by calling... reset_buffer, which ends up creating a new thread while the other still lives.

The result is a new thread that never exits for every full buffer.

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions