Skip to content

Commit

Permalink
change mem check to same values as in v3.6.5, add log
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDvP committed Sep 8, 2024
1 parent beeafd4 commit 6d81525
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/emsdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1903,12 +1903,13 @@ void EMSdevice::mqtt_ha_entity_config_create() {
create_device_config = false; // only create the main config once
count++;
}
// #ifndef EMSESP_STANDALONE
#ifndef EMSESP_STANDALONE
// always create minimum one config
if (count && (heap_caps_get_free_size(MALLOC_CAP_8BIT) < 41 * 1024)) { // checks free Heap+PSRAM
// if (count && (heap_caps_get_free_size(MALLOC_CAP_8BIT) < 41 * 1024)) { // checks free Heap+PSRAM
if (ESP.getMaxAllocHeap() < (6 * 1024) || (!EMSESP::system_.PSram() && ESP.getFreeHeap() < (65 * 1024))) {
break;
}
// #endif
#endif
}
}
#if defined(EMSESP_DEBUG) || defined(EMSESP_STANDALONE)
Expand Down
6 changes: 3 additions & 3 deletions src/mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,13 +613,13 @@ bool Mqtt::queue_message(const uint8_t operation, const std::string & topic, con
// check free mem
#ifndef EMSESP_STANDALONE
// if (ESP.getFreeHeap() < 60 * 1024 || ESP.getMaxAllocHeap() < 40 * 1024) {
// if (!EMSESP::system_.PSram() && (ESP.getFreeHeap() < 60 * 1024 || ESP.getMaxAllocHeap() < 40 * 1024)) {
if (heap_caps_get_free_size(MALLOC_CAP_8BIT) < 40 * 1024) { // checks free Heap+PSRAM
if (!EMSESP::system_.PSram() && (ESP.getFreeHeap() < 60 * 1024 || ESP.getMaxAllocHeap() < 40 * 1024)) {
// if (heap_caps_get_free_size(MALLOC_CAP_8BIT) < 40 * 1024) { // checks free Heap+PSRAM
if (operation == Operation::PUBLISH) {
mqtt_message_id_++;
mqtt_publish_fails_++;
}
LOG_WARNING("%s failed: low memory", operation == Operation::PUBLISH ? "Publish" : operation == Operation::SUBSCRIBE ? "Subscribe" : "Unsubscribe");
LOG_WARNING("%s %s failed: low memory", operation == Operation::PUBLISH ? "Publish" : operation == Operation::SUBSCRIBE ? "Subscribe" : "Unsubscribe", topic.c_str());
return false; // quit
}
if (queuecount_ >= MQTT_QUEUE_MAX_SIZE) {
Expand Down

0 comments on commit 6d81525

Please sign in to comment.