LUA scripts memory limited?
Is there an existing issue for this problem?
- [x] I have searched the existing issues
What part of EdgeTX is the focus of this bug?
Transmitter firmware
Current Behavior
probably for B&W radios only encountered at least as of 2.10.6 on x-lite S.
It seems like scripts that where running fine on earlier versions will not run anymore, probably due to less memory available. It might be the heli page that is now standard loaded and inactivated via the options page, but still eating memory.
Is there an option to build a minimum size runtime? Maximise available memory for LUA scripts?
Expected Behavior
Run scripts that run on the simulator and previous versions on the radio also on the latest version on the radio.
Steps To Reproduce
Load scripts tested on the simulator on the radio, compile on the radio, and run.
Version
2.10.6
Transmitter
FrSky X9 Lite / Lite S, FrSky X-Lite / S / Pro
Operating System (OS)
Windows
OS Version
No response
Anything else?
No response
Speaking as an X-Lite Pro owner: a lot of RAM is required when compiling the LUA script, and EdgeTX seems to compile all of the uncompiled scripts when any are used. First off, remove any script that you don't need (HOTT telemetry, etc). Then try running a script. It will compile, but probably fail to run. Restart your radio (to clear the memory), and try the script again. It should now work. Yes, the Lua engine continues to improve (therefore get bigger), so these X-Lites with their teensy-weensy RAM are starting to struggle. I keep my X-Lite around, but I bought a Zorro with it's larger memory to be my daily driver. I believe some optimizations were done for EdgeTX 2.11, and they added the ability to pre-compile the LUA scripts in Companion so that you no longer have to do the one-time run/crash/reboot/run dance anymore.
I have a small routine that can compile all my files on the radio so they are effectively 'precompiled' after that. But indeed, it was already challenging back then. On opentx the same scripts run, but edge is asking to much for itself apparently.
Well. Thanks for your suggestions.
Perhaps tome to move to a new radio...
It is a known fact that every new compile creates FW that uses more memory. The old unused code is never deleted. Now with the new radio TX15 with the faster cpu, more memory?,the code will get more complex and cause the older cpu's to slow down. That is why I have stopped updating on TX16s at 2.10.6
It is a known fact that every new compile creates FW that uses more memory. The old unused code is never deleted.
Not a fact - just a rude comment with no basis in reality.
In actual fact, a great deal of effort has gone into making EdgeTx better on older hardware. F2 based B&W radios will have approximately 4.8K more free RAM on 2.11, and F4 based radios will over 21K more free RAM for Lua scripts. In addition Lua 5.3 in 2.11 uses less memory and compiles to smaller bytecode further increasing efficiency.
It is a known fact that every new compile creates FW that uses more memory. The old unused code is never deleted.
Not a fact - just a rude comment with no basis in reality.
In actual fact, a great deal of effort has gone into making EdgeTx better on older hardware. F2 based B&W radios will have approximately 4.8K more free RAM on 2.11, and F4 based radios will over 21K more free RAM for Lua scripts. In addition Lua 5.3 in 2.11 uses less memory and compiles to smaller bytecode further increasing efficiency.
Is there a comparison to opentx latest stable version regarding free memory?
My scripts do not run on xlite anymore without serious unstability, and a little better but still unstable on zorro.
Would like to know whete is shoukd try to tune.
The LUA library was updated in v2.11, and they released a couple patches to plug some memory leaks with certain LUA functions. There may still be a memory leak or performance issue with the new library, but we would need to replicate your configuration and scripts to nail it down.
The problem is that the modern radios (such as the new TX15) have so much RAM and speed that such bugs aren't noticeable. You're little X-Lite is a canary in the coal mine. Can you give a detailed list of what LUA scripts you are using, and describe what you're doing when the issues occur?
Thanks for the offer to support. It is already an issue in 2.10 (that I am forced to use due to a bug in the LUA api returned weights on several objects in 2.11). So perhaps I will first try the 2.11 again, as I do think it is memory leakage, since I can recover from the error using a protected function, and keep trying until the script continues.
I will post feedback once tested again on 2.11
OK, I did some testing, and 2.11.3 seems to be much more stable on Zorro. That's good news. Reverted to 2.10.6 and it's problematic again.
Sine I rely heavily on setting weights using LUA, and that is broken as of 2.11.X, I'll just wait for 2.11.4. Hope it will come soon and lua weights are fixed.
For me it can be closed, although there are still situations in which the script will crash for no apparent reason, but relaunching it will work fine. It is rather sporadic and only on very heavy lua script loading tasks.