SignalK / signalk-server

An implementation of a Signal K central server for boats.
http://signalk.org
Apache License 2.0
298 stars 150 forks source link

Excessive memory consumption of tracking sent metadata #1717

Closed tkurki closed 2 months ago

tkurki commented 2 months ago

We are currently tracking sending metadata per ws connection: if we have not sent metadata for a context-path combination we will send metadata and add a marker that is formed from concatenating context & path so that for next value delta we don't send the metadata.

In a busy AIS environment this will cause a lot of string values to be retained for each WebSocket connection: 1000 ais targets x the number of paths per AIS target + self context & paths. The string values are nontrivial, consisting of context + path. The marker keys are formed on the fly, so even if the values are the same for each ws connection they are not shared.

Another problem here is that there is no mechanism for purging this data: the marker values for an AIS target are never cleared, even if the target goes away.

Fixes I can think of: