-->
Page 1 of 2

How much free heap is not enough?

PostPosted: Thu Jul 28, 2016 6:17 pm
by glyn
My ESP has been reporting 23952 free heap; is this plenty or not enough? At what point should I start to get worried about that lack of free heap?

My reason for asking is that I'm trying to debug a crash that occurs after posting a web request and posting to MQTT. Interestingly the crash happens after the https request and MQTT publish execute successfully.

Code: Select allSoft WDT reset

ctx: cont
sp: 3fff2c90 end: 3fff2f80 offset: 01b0

>>>stack>>>
3fff2e40:  4020348a 00001388 00001388 4020347f 
3fff2e50:  3fff307c 000006a0 000006a0 3fff307c 
3fff2e60:  00005900 3fff2f24 00000000 4010053d 
3fff2e70:  000058f4 00003500 000006a0 000006a0 
3fff2e80:  3ffe9411 00000000 3fff1504 3fff2ee0 
3fff2e90:  00005900 3fff2f24 3fff2f24 40202220 
3fff2ea0:  000058f0 00000001 3fff2f24 4020226f 
3fff2eb0:  3ffe95e9 00000016 3fff2f24 4020258d 
3fff2ec0:  3fff307c 000003be 3fff2f24 3fff12f4 
3fff2ed0:  00065187 3fff1e90 3ffe94e7 40202610 
3fff2ee0:  3ffe0000 3fff1e90 3ffe94e7 402138a4 
3fff2ef0:  3fff12e8 3fff1e90 3ffe94e7 402160e2 
3fff2f00:  00000000 00000000 00000000 00000000 
3fff2f10:  00000000 00000000 00000000 00000000 
3fff2f20:  00000000 00000000 000058ef 000058ef 
3fff2f30:  3fff4fec 0000000f 00000000 40215b67 
3fff2f40:  00000000 3fff12ec 40213710 40215dbc 
3fff2f50:  00000000 00000000 00000001 3fff1f4c 
3fff2f60:  3fffdad0 00000000 3fff1f45 40202efc 
3fff2f70:  feefeffe feefeffe 3fff1f60 40204d50 
<<<stack<<<

 ets Jan  8 2013,rst cause:2, boot mode:(3,3)


Here is my code: https://github.com/openenergymonitor/Em ... rc/src.ino

Re: How much free heap is not enough?

PostPosted: Thu Jul 28, 2016 6:30 pm
by martinayotte
You should install the EspExceptionDecoder from https://github.com/me-no-dev/EspExceptionDecoder to get more meaningful stacktrace.

Re: How much free heap is not enough?

PostPosted: Fri Jul 29, 2016 5:04 am
by glyn
Yes, I have installed the debugger. It's bee useful in helping me track the cause of the crash. I actually managed to fix the crashing last night It was due to an incorrect string conversion method.

However, muy initial question still stands: how much free heap is not enough? As I keep expanding my application and free heap keeps reducing when should I get worried? Is there a recommended amount of free heap the ESP requires to run happily or can the free heap by taken down to almost zero by a large application?

Re: How much free heap is not enough?

PostPosted: Fri Jul 29, 2016 8:22 am
by Leonas
glyn wrote:However, muy initial question still stands: how much free heap is not enough? As I keep expanding my application and free heap keeps reducing when should I get worried? Is there a recommended amount of free heap the ESP requires to run happily or can the free heap by taken down to almost zero by a large application?
My program is also reasonably large and when the web server is started the heap gets down to around 12.000. Below 9000 some of my larger pages (7 KB on disk, not internal memory) are not handled anymore and that for example happens when there's no WiFi STA available and I need to start my own AP. So I limited the number of pages the client can connect to (they are not necessary in AP mode anyway) and I am shaving the html to get it as small as possible without losing functionality. That worked so far.
It looks like you still have some room to grow (shrink the heap). :D