- Mon Dec 01, 2014 7:18 am
#3680
GeoNomad wrote:Maybe I just don't know how to use Lua yet, but this was causing issues and I narrowed it down to a test case:
Code: Select all
NodeMcu 0.9.2 build 20141124 powered by Lua 5.1.4
> tmr.stop()
>
> if (cat == nil) then
>> cat = 5
>> end
> print(node.heap())
20360
>
> if (cat == nil) then
>> cat = 5
>> end
> print(node.heap())
19784
>
> if (cat == nil) then
>> cat = 5
>> end
> print(node.heap())
19056
>
> if (cat == nil) then
>> cat = 5
>> end
> print(node.heap())
18480
>
If I am doing something wrong, or if this has been fixed in the past week, please let me know.
Hi
just found out - don't rely on any memory-related tests entered directly into the commandline-interpreter
put the above code into a file and make a dofile:
Code: Select all> node.restart()
> �!
�����!��1�)]��
lua: cannot open init.lua
NodeMcu 0.9.2 build 20141130 powered by Lua 5.1.4
> dofile("ifi")
20288
20248
20248
20248
The commandline seems to lack memory management completely - be patient and enter/paste the following highly sophisticated code about 70 times:
Code: Select all> print AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
of course, you'll get a syntax error every time but at the end you'll get:
Code: Select allmalloc: not enough memory
lua: not enough memory
(or a reboot)
... so all tests should be done via dofile() and restart your module before if you want to get reliable results regarding later 'real world' - use!
Thomas