Skip to content

Memory leak in SharedClientStateServer #511

Closed
@rmorshea

Description

@rmorshea

I've stumbled upon another memory leak, this time in SharedClientStateServer. Try this:

import idom
from idom.server.sanic import SharedClientStateServer

@idom.component
def SomeComponent():
    ticks, set_ticks = idom.hooks.use_state(0)
    set_ticks(ticks + 1)
    return idom.html.div()

server = SharedClientStateServer(SomeComponent)
server.run("127.0.0.1", 8000)

If you open the browser window, and then exit it, the process memory runs amok. Again, this is primarily driven by frequent state changes - if you use my original example and reduce the ticker interval, it does not occur. However, if you create a lot of elements dependent on that state (e.g. 1000 buttons but a 0.1s timer), it happens again. The issue I have in practice is that I believe the leak still occurs in a normal application if you exit the browser window at an inconvenient time - and this is the closest example I've been able to come up with.

Originally posted by @mx781 in #509 (reply in thread)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions