Timeline for How to fix memory-leak code in ESP8266/NodeMCU caused by string concenation?
Current License: CC BY-SA 4.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 23, 2020 at 1:59 | history | edited | hcheung | CC BY-SA 4.0 |
added 64 characters in body
|
May 20, 2020 at 5:59 | vote | accept | Frodik | ||
May 19, 2020 at 12:49 | comment | added | Edgar Bonet |
Re "[heap allocation] is happening for each iteration of the while loop": on the ESP8266, it happens once every 16 iterations, as the allocated size is grown by multiples of 16 bytes. Re "if your while loop is within a function, the part of the heap might be free-up at the exit of the function": when concat() can't manage to grow the string in place, it will allocate a new buffer, copy the existing data, and free the previous buffer right away. This doesn't invalidate your point about the risk of memory fragmentation though.
|
|
May 19, 2020 at 7:00 | history | edited | hcheung | CC BY-SA 4.0 |
added 226 characters in body
|
May 19, 2020 at 6:39 | history | edited | hcheung | CC BY-SA 4.0 |
added 97 characters in body
|
May 19, 2020 at 6:32 | history | answered | hcheung | CC BY-SA 4.0 |