mzimmers wrote: ↑
Wed Feb 19, 2020 2:29 am
Hi Angus - I'll try those memory reports you suggested in the morning.
I'm not sure I understand - are you saying that there would be expected to be *more* memory available than what I'm showing in the reports? It looks like I have plenty of the 8-bit (which from what I understand is what malloc() uses).
It seems strange that I'd be short on memory now that I've enabled SPI RAM, as I had enough memory without SPI RAM before I went to v4.1. Something just isn't right.
You have plenty of 8-bit memory, but not plenty of "internal" 8-bit memory (MALLOC_CAP_INTERNAL and MALLOC_CAP_DMA). Some functions allocate internal-only RAM because they need to use DMA, need to use the memory from an interrupt when SPI flash may be being written, or for performance reasons. In particular the Wi-Fi library uses some internal 8-bit memory.
There's some more general info about this here:
https://docs.espressif.com/projects/esp ... alloc.html
According to the startup log there's almost 220KB of heap memory initialized in internal DRAM (89+6+111+14). According to the "memreport" log there's 5932 bytes of internal memory left at some point after initial startup. So something has definitely allocated a lot of internal memory.
Note that the default "malloc" behaviour (for allocations where you don't require a particular type of memory) is to favour internal memory for small allocations, and external memory for large allocations. The threshold between "small" and "large" is set in a config item:
https://docs.espressif.com/projects/esp ... ysinternal
(Although this says "always", if internal memory is full and the allocation is a plain malloc() which doesn't require internal memory then the small allocation will fail over to external memory as well, if there's no more internal memory.)
So one thing you could try is tuning that config item down, to encourage more of the small allocations to use up external memory and leave internal memory full. But if you don't have any prime suspect for what is using over 200KB of heap on startup then it may be worth figuring this out, first.
I was commenting on the inaccuracy in the docs:
https://docs.espressif.com/projects/esp ... /wifi.html
s1.2: The main task calls esp_event_loop_init() to create a system Event task and initialize an application event’s callback function.
It's my understanding that this call is deprecated in V4.1. So, this would seem to be an error in the docs. If this is there, there may be more errors.
Thanks for pointing this out, looks like this wasn't updated when the event library was updated. Will get this fixed. The part of this document describing in the inner workings of the Wi-Fi library is still accurate, as far as I know (the change here is in the app side).