Reputation: 15488
Using the cloud compiling website I created a custom NodeMCU firmware that has a lot of modules. So many that the firmware itself is almost 700KB in size. I usually only use up to 5 modules for a single project, so I'm wondering if the inclusion of all the other modules in the firmware have a noticeable negative impact on the RAM usage.
Upvotes: 1
Views: 443
Reputation: 23525
There's an excellent explanation of the ESP8266 memory map (and other interesting bits) at https://www.kickstarter.com/projects/214379695/micropython-on-the-esp8266-beautifully-easy-iot/posts/1501224. Furthermore, you got a great answer as a comment.
Every module baked into the binary consumes memory just by "being there". If you wanted to measure the impact a single module has on the available heap you'd have to build two binaries, one with and one without that module. You'd flash both and calculate the delta of running node.heap()
right after start.
Does compiling NodeMCU with lots of modules have an impact on the memory usage?
Yes, it definitely does as you noticed.
I usually only use up to 5 modules for a single project
That's why we recommend to use a different set (read "minimal set") of modules for every project. The beauty of the NodeMCU firmware is that you only have to do this once, contrary to e.g. Arduino, after which swapping scripts or even individual functions in'n out is super quick.
I suggest you also take a look at https://nodemcu.readthedocs.io/en/dev/en/lua-developer-faq/#techniques-for-reducing-ram-and-spiffs-footprint. A major overhaul is in the making at https://github.com/nodemcu/nodemcu-firmware/pull/1899.
Upvotes: 2