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

User avatar
By LeprA
#18640
TerryE wrote:The tmr.delay() argument is in µSec, so a delay of 1 µSec is going to look like its not working.

Setting _G.tmr = nil is a bad idea. This will cause tmr to be re-resolved on each reference with the sort of leak that you see.

The leak is showing even if i remove the "tmr = nil" I just added that to see if i got a different result sorry for getting that in the example.
But its good to know that i should not set it up like that.

The thing is that it would not do any difference between having 1us or 1000us
in the example there i set tmr to a local variable.
User avatar
By LeprA
#18644
cal wrote:Moin,

IMHO lua is mostly a glue or prototype language.
If you identify proper functions that need speed, encode them in c and call them from lua.

My € 0,02 cents,
Cal


Yes i understand that!

It still should not leak memory even if people use it for prototyping, but that's my opinion maybe.
I wanted to know why the LUA code "tmr" leaks memory and why it do not work if i put the tmr into a local variable.
I tried to figured it out by looking at the C implementation but i could not figure it out.
User avatar
By LeprA
#18646
cwilt wrote:You will gain far more speed if you convert gpio.write, gpio.HIGH, and gpio.LOW to local variables. Using a tight loop and setting CPU speed to max I recorded a gpio toggle of 124khz.


Thanks for the tip, i will look into that then i have solved the memory problem and/or why not a local tmr works.
User avatar
By cal
#18653
LeprA wrote:
cal wrote:Moin,

IMHO lua is mostly a glue or prototype language.
If you identify proper functions that need speed, encode them in c and call them from lua.

My € 0,02 cents,
Cal


Yes i understand that!

It still should not leak memory even if people use it for prototyping, but that's my opinion maybe.
I wanted to know why the LUA code "tmr" leaks memory and why it do not work if i put the tmr into a local variable.
I tried to figured it out by looking at the C implementation but i could not figure it out.



My answer was meant for lepra.
I totally agree with you. There should be no memory leak.

Cal