Left here for archival purposes.

User avatar
By GeoNomad
#3638 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.
User avatar
By ThomasW
#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
User avatar
By GeoNomad
#3762
ThomasW wrote: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:


Bingo! That is very helpful.

I have put my cat into a file and am updating LuaLoader to use the created function.

Code: Select allfunction cat( fname )
   file.open( fname, "r")
   while true do
      local line = file.readline()
      if (line == nil) then break end
      print(string.sub(line, 1, -2))
      end
   file.close()
end
User avatar
By zeroday
#3938
ThomasW wrote:
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


fix this "print AAA" thing in the new build 20141204