-
Notifications
You must be signed in to change notification settings - Fork 182
esp_websocket_client: Add Kconfig options for PSRAM allocation (IDFGH-17011) #980
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
Open
shardt68
wants to merge
1
commit into
espressif:master
Choose a base branch
from
shardt68:feature/websocket_psram_stack_config
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
esp_websocket_client: Add Kconfig options for PSRAM allocation (IDFGH-17011) #980
shardt68
wants to merge
1
commit into
espressif:master
from
shardt68:feature/websocket_psram_stack_config
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
13277dd to
27c4e4b
Compare
27c4e4b to
8a75888
Compare
8a75888 to
b683518
Compare
b683518 to
6c381b9
Compare
6c381b9 to
e84c0eb
Compare
cbf6bad to
016bf62
Compare
016bf62 to
0ae9008
Compare
15cba04 to
9d9f1c9
Compare
- Added CONFIG_ESP_WS_CLIENT_TASK_STACK_IN_EXT_RAM to allow allocating WebSocket task stack in PSRAM. - Added CONFIG_ESP_WS_CLIENT_ENABLE_DYNAMIC_BUFFER to allow dynamic allocation of RX/TX buffers. - Fixed memory leak in esp_websocket_client_destroy by deferring destruction to a separate task when called from the WebSocket task itself. - Fixed stack size calculation for xTaskCreateStaticPinnedToCore (expecting words). - Fixed race conditions and use-after-free in task destruction by using vTaskSuspend + vTaskDelete pattern instead of self-deletion. - Fixed double-free race condition in destroy_on_exit where manual destroy could race with deferred destruction. - Fixed deferred destruction never completing when called from task. - Fixed suspended task leak when STOPPED_BIT is already set.
9d9f1c9 to
391fb0b
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces two new Kconfig options to the
esp_websocket_clientcomponent to allow memory allocation in external RAM (PSRAM):ESP_WS_CLIENT_TASK_STACK_IN_EXT_RAM: Enables allocation of the WebSocket task stack in PSRAM usingxTaskCreateStaticPinnedToCore.ESP_WS_CLIENT_ALLOC_IN_EXT_RAM: Enables allocation of theesp_websocket_clientstructure and its internal configuration storage in PSRAM.Motivation
In applications requiring multiple concurrent secure connections (e.g., TLS/HTTPS), internal RAM is a critical bottleneck. Each TLS session typically requires 16-20KB of internal RAM for buffers. By allowing the WebSocket client's task stack and internal structures to be moved to PSRAM, significant internal memory is freed for these critical network operations, improving overall system stability and preventing
ESP_ERR_NO_MEMfailures in memory-constrained scenarios.Implementation Details
heap_caps_callocwithMALLOC_CAP_SPIRAMfor the client structure and config.xTaskCreateStaticPinnedToCorefor the task stack when PSRAM is selected.Related
Testing
heap_caps_get_free_sizethat internal RAM usage decreased by the expected amount (~5KB for structure + stack size).Note
Enables optional PSRAM usage and improves lifecycle safety for the WebSocket client.
ESP_WS_CLIENT_TASK_STACK_IN_EXT_RAMandESP_WS_CLIENT_ALLOC_IN_EXT_RAMto allocate task stack and client/config in PSRAMxTaskCreateStaticPinnedToCorewith PSRAM stack and internal-RAM TCB; falls back to internal RAM if allocation failstask_stack_bufferandtask_bufferfields; ensures they are freed; clearsstatus_bitsafter deletionDESTRUCTION_IN_PROGRESS_BIT, defers self-destruction viaws_destroytask, suspends task before deletion, and prevents double-destroy;stop_wait_tasknow waits for suspension then deletes the taskWritten by Cursor Bugbot for commit 391fb0b. This will update automatically on new commits. Configure here.