miguelgrinberg / turbo-flask

Integration of Hotwire's Turbo library with Flask.
MIT License
301 stars 35 forks source link

Memory leak when page is not in focus (Edge 103) #36

Open danilofuchs opened 2 years ago

danilofuchs commented 2 years ago

Issue Description

Webpage memory consumption is increasing over time, reaching over 3GB if the tab is not in focus, leading to a freeze with an out-of-memory error code.

If page goes back in focus or is refreshed, consumption is stable at 100MB.

Elements are being created and removed every 1 second, but it looks like old elements are not garbage collected when the tab is on background.

(readings from the chromium task manager)

Setup

Turbo-Flask 0.8.0 Flask 2.1.2 Python 3.7.8 Microsoft Edge 103.0.1264.62

Use Case

Web page for monitoring a long running process.

Multiple variables update every 1 second, using turbo.update

turbo.push(turbo.update(
    render_template(
        'content_targets.html',
        targets=monitor.targets,
        metadata=monitor.metadata
     ),
     'targets'
    )
)

This recreates the entire web page every 1 second. On the dev tools, it is possible to see the DOM tree being updated.

miguelgrinberg commented 2 years ago

Turbo-Flask does not run in the browser. You may need to submit this issue to the hotwired team: https://github.com/hotwired/turbo

danilofuchs commented 2 years ago

Tagging the Turbo issue: https://github.com/hotwired/turbo/issues/639