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

User avatar
By draco
#13757 Yes, dealing with the tight memory constraints can be frustrating.
Your script does not LOOK too huge... Are you loading some other scripts in addition to this one that might be using up your memory? Maybe you have some stuff in init.lua that is sucking up memory?

The node.heap() function will tell you how much memory is unused/available at any point. It's useful for hunting down things that may be taking up way more memory than you thought they might. Maybe run a few simple experiments similar to this:
Code: Select allprint(node.heap())
ds18b20 = require("ds18b20")
print(node.heap())

Which will tell you your available memory before and after loading the library.

Another trick to squeeze out a little extra memory is compiling the LUA. node.compile("myscript.lua") will create a "myscript.lc". Then you can dofile("myscript.lc") without your raw script loaded into memory, giving you a little more free memory.

As an aside, notice in my example that i am assigning the result of the require() call to a variable and then using that variable... I believe that's mandatory, so that might be one problem with your script. You'll be trying to call the .setup() method on a ds18b20 object that hasn't been created.
User avatar
By faramon
#82189 what is the limit of variable within require("file")?

I have same problem with not enough memory but my script is long 445 lines but I think that this is not memory problem because the same script was great until I add 20 lines of code into... I remove and upload script from backup but now it always getting error not enough memory no matter scripts is from backup (that ws working great) or new one...