As the title says... Chat on...

User avatar
By stozk
#17699 Hi,

I have a script which works flawlessly on a nodemcu devkit module, but when I flash it on an ESP12 or ESP03 I'll get a "lua: not enough memory" message and the script won't execute at all.

Shouldn't it behave exactly the same or is there something special with the nodemcu devkit?

Thanks & BR
Daniel
User avatar
By stozk
#17718 I just tried to run my code which always worked and worked yesterday night on my nodemcu devkit and it won't run now showing the same error "lua: not enough memory".

What the hell? How can it suddenly stop working? Does anyone have an idea?
User avatar
By TerryE
#17751 It sounds like your scipt is on the knife edge of running out of RAM. There's lots of reasons why this might occur on one device befre another -- for example they're running different nodeMCU builds.

What you should focus on is how to reduce your RAM footprint. There a quite a few posts on this, but the simplest approach is to decompose your code into separate modules and link from one to another with events, e.g. tmr.alarms(); sk:on(XXX, f) call backs. etc. For example do all of your initiatialisation in one module with all working variables as local and pass any context to the others as global variables. That way the garbage collector will remove off of the memory used for initialisation before executing the main processing -- if it has been fully dereferenced.
User avatar
By stozk
#17782 Thanks, looks like RAM is really on edge here. I cut one variable and it not at least executes on the ESP12 Standalone chip normally again, but the ESP03 is still running out of memory.

I even compiled a custom firmware and removed all the non needed nodemcu modules.

I'll keep experimenting with the esp03 and try a few other modules. I have modded a small powerbank and turned it into one of those pushbuttons which will trigger an online API and the 03's footprint is perfect, the 12 is sadly to big by only a few mm's.