Current Lua downloadable firmware will be posted here

User avatar
By TerryE
#19665 Cal,

My experience is that PANICs tend to occur for one of two main categories of reason
  1. You've called an invalid target: either simply a mistype in the method name or your "table" / object ref is no longer in scope or
  2. You've ran out of RAM.
In both of these then there's little that you can do other than die. Certainly as far as I am concerned, I can rapidly identify which line of code crapped out, and if its a typo then fix it. Identifying why a resource leak is occurring is an entirely different matter, because I avoid the usual bear traps and what those that are left are difficult to diagnose. A good example that I see is where users do a bunch of sk:send() calls not realising that queuing these eats RAM.

We constantly have a trade-off and a dilemma with the ESP8266 -- There is always a temptation to add extra functionality / validation etc. but we then bitch because there's not enough RAM left to run our application, or we upgrade the firmware to a new version to clear a few bugs, only to discover our application no longer fits. I am not sure what the answer is here, though custom builds where you can omit modules that you don't use does help.
User avatar
By cal
#19674 Terry,

I mainly agree.
But when you do some "nil" access in a callback which is the *standard* way in nodemcu
I think we should at least print the stacktrace before panic is done.

Regarding memory: its mostly heap we talk about, not code. Even less of a problem with bigger flash sizes.

Why do we need more memory than 1 pointer to module data of heap mem for unused modules?
Modules can be kind of "loaded" and that allocates the module memory from heap and sets up the pointer
to module memory.

Cal