When I program a PIC controller, MPLAB IDE has a memory usage gauge, to indicate how much memory my code is using up. Is there anything like this for ESP32 ?
Thank you,
Trevor
I’ve tried Serial.println(ESP.getFreeHeap()); and got this serial monitor output.
Thanks for the reply,
I’m trying to gauge the size of my code and thus, whether I’ll run into memory limits, as I develop further.
So free heap = 342620 / 1024 = 334kB.
Does this mean I’ve used 512 - 334 kB = 178kB for my code ?
Trevor
Did a bit of Googling and found a post detailing the POI built in Program Memory Usage calculator, which looks ideal.
Looked in Platformio/Project tasks/nodemcu-32s/Platform and clicked PROGRAM SIZE.
However, I got the following results …
PLATFORM: Espressif 32 (6.12.0) > NodeMCU-32S
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
Calculating size .pio\build\nodemcu-32s\firmware.elf
text data bss dec hex filename
292757 115956 5953 414666 653ca .pio\build\nodemcu-32s\firmware.elf
I’m now even more confused.
If my program uses 414666 bytes (404.94 kB), how does it fit into 320kB of RAM ?
HI Boris,
Hope you are well ?
I’m sure it’s far more complicated than my current understanding of this subject.
I’m just trying to work out how much memory space is available, for the rest of my project development, which might double the size of my code.
I read a post the other day about someone running out of memory on an ESP32 project and I suddenly thought “oooops, I haven’t considered that !”
So, I now have those numbers, but don’t understand what they mean.
I can’t find a clear explanation of those numbers.
After uploading my code to the ESP32, I read the following at the bottom of the terminal window … Wrote 407152 bytes (239574 compressed) at 0x00010000 in 6.0 seconds (effective 540.7 kbit/s)...
Does this mean “233.95KB of 520KB used” ?
i.e. 286KB still available ?
No, because this is about how much of the FLASH is used. The available FLASH memory on an ESP32 depends on how much memory the physical FLASH chip provides and the used partition layout.
Basically: The code you write goes into FLASH memory. Every variable your sketch is using goes into RAM.
Ooooh very interesting reading, a lot clearer than other things I’ve found, thanks Boris. Think I understand a bit better now.
Interesting to read the “String Wrapper” section about using the F() string wrapper in “Serial.print” or “Serial.println” instructions, to free up SRAM space. But, why have I not seen this in any tutorials or code examples ?
I have found some information, to answer my own question, people might find useful.
During project build, the terminal window does give memory usage information, if you scroll
back through it.
My current project gives this …
Retrieving maximum program size .pio\build\nodemcu-32s\firmware.elf
Checking size .pio\build\nodemcu-32s\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [= ] 7.6% (used 25040 bytes from 327680 bytes)
Flash: [=== ] 32.0% (used 419781 bytes from 1310720 bytes)
I’ve also discovered in Platformio “HOME”, the “Inspect” function gives the same information.