mirror of
https://github.com/esphome/esphome.git
synced 2024-12-23 14:04:53 +01:00
Actually increase request memory for json parsing (#3331)
This commit is contained in:
parent
fc94a5d0ee
commit
bb5f7249a6
1 changed files with 3 additions and 3 deletions
|
@ -54,9 +54,8 @@ void parse_json(const std::string &data, const json_parse_t &f) {
|
|||
const size_t free_heap = heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL);
|
||||
#endif
|
||||
bool pass = false;
|
||||
size_t request_size = std::min(free_heap - 2048, (size_t)(data.size() * 1.5));
|
||||
do {
|
||||
const size_t request_size = std::min(free_heap - 2048, (size_t)(data.size() * 1.5));
|
||||
|
||||
DynamicJsonDocument json_document(request_size);
|
||||
if (json_document.memoryPool().buffer() == nullptr) {
|
||||
ESP_LOGE(TAG, "Could not allocate memory for JSON document! Requested %u bytes, free heap: %u", request_size,
|
||||
|
@ -76,7 +75,8 @@ void parse_json(const std::string &data, const json_parse_t &f) {
|
|||
ESP_LOGE(TAG, "Can not allocate more memory for deserialization. Consider making source string smaller");
|
||||
return;
|
||||
}
|
||||
ESP_LOGW(TAG, "Increasing memory allocation.");
|
||||
ESP_LOGV(TAG, "Increasing memory allocation.");
|
||||
request_size *= 2;
|
||||
continue;
|
||||
} else {
|
||||
ESP_LOGE(TAG, "JSON parse error: %s", err.c_str());
|
||||
|
|
Loading…
Reference in a new issue