Skip to content

Commit

Permalink
debugging memory
Browse files Browse the repository at this point in the history
  • Loading branch information
stintel committed Jul 23, 2023
1 parent b72390f commit d7101f2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions main/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ char *config_get_char(char *key)
char *ret = NULL;
cJSON *val = cJSON_GetObjectItemCaseSensitive(wc, key);
if (cJSON_IsString(val) && val->valuestring != NULL) {
ESP_LOGI(TAG, "potentially leaking %d bytes of memory", strlen(val->valuestring));
ret = strndup(val->valuestring, strlen(val->valuestring));
} else {
ESP_LOGW(TAG, "key %s not found in config, use bogus value to avoid NULL pointer dereference", key);
ESP_LOGI(TAG, "potentially leaking %d bytes of memory", 6);
ret = strndup("bogus", 6);
}
return ret;
Expand Down
5 changes: 5 additions & 0 deletions main/endpoint/hass.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@ static void hass_post(const char *data)
free(body);

free(url);

ESP_LOGI(TAG, "min_free_iram: %d", heap_caps_get_minimum_free_size(MALLOC_CAP_INTERNAL));
ESP_LOGI(TAG, "min_free_spiram: %d", heap_caps_get_minimum_free_size(MALLOC_CAP_SPIRAM));
}

static void hass_send_ws(const char *data)
Expand Down Expand Up @@ -410,6 +413,8 @@ static void hass_send_ws(const char *data)
ESP_LOGE(TAG, "failed to send command via WebSocket client");
}
cJSON_Delete(cjson);
ESP_LOGI(TAG, "min_free_iram: %d", heap_caps_get_minimum_free_size(MALLOC_CAP_INTERNAL));
ESP_LOGI(TAG, "min_free_spiram: %d", heap_caps_get_minimum_free_size(MALLOC_CAP_SPIRAM));
}

void hass_send(const char *data)
Expand Down
2 changes: 2 additions & 0 deletions main/endpoint/rest.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ void rest_send(const char *data)
lvgl_port_unlock();
}

ESP_LOGI(TAG, "min_free_iram: %d", heap_caps_get_minimum_free_size(MALLOC_CAP_INTERNAL));
ESP_LOGI(TAG, "min_free_spiram: %d", heap_caps_get_minimum_free_size(MALLOC_CAP_SPIRAM));
reset_timer(hdl_display_timer, DISPLAY_TIMEOUT_US, false);

free(body);
Expand Down

0 comments on commit d7101f2

Please sign in to comment.