hotwired / turbo

The speed of a single-page web application without having to write any JavaScript
https://turbo.hotwired.dev
MIT License
6.71k stars 427 forks source link

Frame updated from Turbo Stream - StreamSteadily increasing memory allocated with Chrome tab #705

Open benjaminrau opened 2 years ago

benjaminrau commented 2 years ago

Hi there.

We use the latest version of Hotwired Turbo on a machine dashboard containing a list of events on a turbo stream (fed by SSE) which uses "replace" action.

We observe a steadily increasing memory allocation with (long running) Chrome (latest version) tabs showing that stream mentioned above. There is a direct correlation between the number / frequency of /messages sent on fe (read: updates of the stream element) and the growth of memory alllocation over time.

Messages on the SSE connection are emitted on demand (on change) by throttled to a max of every 500 ms. After about 80 minutes there memory consumption was at 2.2 GB before it crashed.

There is no difference is our observations if the chrome tab is in focus or not.

Is there any configuration we missed to ensure there is some kind of garbage collection taking place, or should it be default?

Greetings Ben

seanpdoyle commented 2 years ago

@benjaminrau thank you for opening this issue.

Could you share some of the contents of the replace Turbo Streams?

Do the elements inserted by the Stream participate in any MutationObservers or Event Listeners? Do they connect Stimulus controllers or any kind? Do those controllers initialize plugins?