Skip to content
This repository was archived by the owner on Aug 10, 2024. It is now read-only.
This repository was archived by the owner on Aug 10, 2024. It is now read-only.

Memory leaks due to un-GCable event handlers #194

@alkoclick

Description

@alkoclick

Hey folks! Long time no see!

I come bearing some good and bad news. Let's start with the bad ones: Memory leak.

Describe the bug
Here's our memory usage in Kweb, over a day:
image

It's honestly not great. The 04:00 drop on the left is because we actually have a nightly restart in place for the container, because just GCing wasn't good enough.

To Reproduce
Run any Kweb app for more than 24 hours. You'll start noticing leftovers from client sessions in memory.

Expected behavior
Kweb allows the GC to clean up disconnected clients faster and does not keep references to callbacks on

Summary of our current understanding

Here's what the GC chain looks like:
image

You'll notice that the reference that is kept is actually a listener.

Suggested paths forward

Remove listeners from the client state properly

I honestly don't have too much insight in this. I really doubt these handlers should stay open after a client disconnect, so I suspect one of the cleanups is not running properly.

Allow configuring client cleanup timeout

So this is the good news I guess. While I might misunderstand the functionality here, I believe that enabling faster client cleanups, can partially alleviate this problem and is a good value to have configurable in the long term. I've implemented this at the PR: #193

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions