Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4. Improve memory usage related to websocket #182

Closed
wants to merge 1 commit into from

Conversation

mathieucarbou
Copy link
Contributor

@mathieucarbou mathieucarbou commented Dec 11, 2023

This PR introduces DASH_PARTIAL_UPDATE_JSON_SIZE (defaulted to DASH_LAYOUT_JSON_SIZE for backward compatibility). This allows to reduce the reserved memory for most of the subsequent websocket push after the initial load of the page.

Also introduced DASH_MAX_WS_CLIENTS (defaulted to DEFAULT_MAX_WS_CLIENTS) to allow controlling the maximum number of WebSocket clients for DASH. The default is 8 for ESP32 (comes from the ESPAsyncWebServer lib).

The cleanup code has been added to make sure, before doing a WS push, that older clients gets closed in case the count is more than the allowed limit.

Also, a quick check has been added to avoid doing any memory intensive operation when the app triggers and dashboard.update() in case there is no client connected.

Also added hasClient() to allow callers to know if some WS clients are connected (i.e. to improve the update code to avoid running it)

@mathieucarbou mathieucarbou changed the title Improve memory usage related to websocket 4. Improve memory usage related to websocket Dec 12, 2023
@mathieucarbou mathieucarbou deleted the websocket branch December 16, 2023 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant