Advanced Users can post their questions and comments here for the not so Newbie crowd.

Moderator: eriksl

User avatar
By davydnorris
#82493 If you get a detailed memory map from the build, you'll at least be able to see where your RAM is going, and then you can start looking at moving functions and data to flash. I found using -DUSE_OPTIMIZE_PRINTF made a big difference as it moved all printf strings into flash. I also found I had a couple of functions that I had left the ICACHE_FLASH_ATTR directive off - I now only have a couple of interrupt service routines that are in RAM.

The other thing I found was that there are several problems with the default esp_mqtt code, and one that may be affecting you is that it allocates a 2kB data array on the heap during publish routines, but this is only used when there is a publish buffer overrun to clear the oldest message from the buffer. I changed this to a malloc inside the error handling if statement instead. This made a big difference to the amount of free heap I had at crucial moments

I also found I could set the SSL size to 4096 for MQTT and still publish everything I needed to, however I needed 5120 for HTTPS calls to a different server, so it's highly dependent on where you're connecting - have a play reducing the value for your site and you may find you can get away with less.
User avatar
By Solomon Candy
#82529 I got 70k free DRAM on my latest - RTOS-3.1 - build !! On NONOS-2 I got about 48k I think.
That is after running LWIP with mdns and a TCP connection and a couple of my own libs.

BTW porting from NONOS to RTOS is really easy, except the espconn part. There is nothing to port otherwise really except changing the header files, and the create process calls if you used processes in NONOS in the first place. I was really clinging to NONOS for a long time but when I was forced to make the change, it was eeasy-peasy.