ruuvi / ruuvi.gateway_esp.c

Ruuvi Gateway ESP32 code
BSD 3-Clause "New" or "Revised" License
24 stars 15 forks source link

Fix #969: Gateway sometimes reboots due to erroneous detection of memory leaks #971

Closed TheSomeMan closed 5 months ago

ojousima commented 5 months ago

Do we detect allocation failures somewhere? Or does the max_free_heap limit guarantee that there is enough memory for normal operation?

TheSomeMan commented 5 months ago

Do we detect allocation failures somewhere? Or does the max_free_heap limit guarantee that there is enough memory for normal operation?

In many cases, allocation failure is not critical (sometimes it happens because of memory fragmentation). For example, if there is not enough memory while sending data to the HTTP target, we can just retry this operation. Yes, max_free_heap limit guarantees that it's enough to perform data sending over HTTPS. And if we have less memory than 50KB, then it is highly likely that a memory allocation error will occur when sending data. So, if the amount of memory in the system for a long time is less than this limit, there may be a memory leak somewhere and it is safer to reboot the gateway so that HTTPS/MQTTS connections are guaranteed to open.

sonarcloud[bot] commented 5 months ago

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud