RDKB-63687 Code development to reduce SM app memory usage#921
RDKB-63687 Code development to reduce SM app memory usage#921skarth597 wants to merge 9 commits intordkcentral:developfrom
Conversation
Reason for change: for onboarding Test Procedure: Debug Priority: P0 Risks: Low Signed-off-by: Samyuktha Karthikeyan <samyuktha_karthikeyan@comcast.com>
There was a problem hiding this comment.
Pull request overview
This PR reduces SM app memory usage by changing client_assoc_stats from a fixed-size per-MAX_NUM_RADIOS global array to a dynamically allocated buffer sized to the runtime number of radios.
Changes:
- Replaced
client_assoc_stats[MAX_NUM_RADIOS]with a heap-allocatedclient_assoc_statspointer. - Allocated
client_assoc_statsduringsm_init()usinggetNumberRadios()and freed it duringsm_deinit().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| client_assoc_stats = calloc(radios_count, sizeof(client_assoc_stats_t)); | ||
| if (client_assoc_stats == NULL) { | ||
| wifi_util_error_print(WIFI_SM, "%s:%d: calloc failed for client_assoc_stats\n", __func__, __LINE__); | ||
| return RETURN_ERR; | ||
| } | ||
| rc = sm_report_init(app); | ||
|
|
There was a problem hiding this comment.
If sm_report_init(app) fails, sm_init() returns an error but client_assoc_stats (allocated here) is not freed, and the newly-created maps also remain allocated. Add cleanup on the failure path (free client_assoc_stats, destroy sm_stats_config_map / report_tasks_map, etc.), or refactor sm_init() to a single goto-based cleanup block.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
Reason for change: To reduce the SM app memory usage Test Procedure: Debug Priority: P1 Risks: Low Signed-off-by: Samyuktha Karthikeyan <samyuktha_karthikeyan@comcast.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| client_assoc_stats = calloc(radios_count, sizeof(client_assoc_stats_t)); | ||
| if (client_assoc_stats == NULL) { | ||
| wifi_util_error_print(WIFI_SM, "%s:%d: calloc failed for client_assoc_stats\n", __func__, __LINE__); | ||
| return RETURN_ERR; |
There was a problem hiding this comment.
On the calloc failure path, sm_stats_config_map and report_tasks_map have already been created, but the function returns immediately without destroying them. Add cleanup for those allocations (and any other init steps in this function) before returning to avoid leaks when SM init fails early.
| rc = sm_report_init(app); | ||
| if (rc != RETURN_OK) { | ||
| free(client_assoc_stats); | ||
| client_assoc_stats = NULL; | ||
| } |
There was a problem hiding this comment.
If sm_report_init(app) fails, this code frees client_assoc_stats but leaves sm_stats_config_map / report_tasks_map allocated and returns the error. Please add a consolidated failure cleanup path (e.g., goto cleanup) that also destroys these maps (and any other partially-initialized resources) before returning.
Reason for change: To reduce the SM app memory usage Test Procedure: Debug Priority: P1 Risks: Low Signed-off-by: Samyuktha Karthikeyan <samyuktha_karthikeyan@comcast.com>
Reason for change: To reduce the SM app memory usage
Test Procedure: Debug
Priority: P1
Risks: Low
Signed-off-by: Samyuktha Karthikeyan samyuktha_karthikeyan@comcast.com