How do we know what is the safe value of free heap 10% 20% ?
what is mgos_get_min_free_heap_size()
told us ?
compare to mgos_get_free_heap_size()
How do we know what is the needed size of a queue ? The safe value for a stack ?
Unfortunately is not a percentage, variables have a fixed length and not a proportion of the available memory, so a system that uses 20K for variable storage will still use 20K on a 32K micro and on a 256K micro.
Now, in systems like the ESP8266 or the ESP32, things are a bit more complicated, so those two functions will help you. Check for rules of thumb, usually less than 20K is calling for trouble but it depends on the OS version, latest releases required more memory IIRC. Calls to *alloc() functions use the heap, so you have to tune your system.
Last time I read the docs, they said
https://mongoose-os.com/docs/mongoose-os/api/core/mgos_system.h.md#mgos_get_min_free_heap_size
and
https://mongoose-os.com/docs/mongoose-os/api/core/mgos_system.h.md#mgos_get_free_heap_size
respectively
“minimal watermark” means the minimum value registered. The second function is the actual value, now; the first one is historic, persistent, since boot time, monotonically decreasing.
That will say on ESP32 if memory free are remain above 50K will be no issue. I’m not talking about memory leaking during some process. just for overall concept.