ardupilot
ardupilot copied to clipboard
AP_Scripting: reduce Lua state memory usage
A few re-engineerings to make the state setup more efficient and on-demand. Please see the commits for details.
There are no visible changes to scripts except for ones that play games reading _ENV, which none in the repo do. There might be a slight downside of increased risk of fragmentation and out of memory problems at inopportune moments, but I think the savings are worth it.
Tested some scripts including my REPL in SITL and on Cube Orange.
Total savings on Cube Orange:
- 104 bytes of statically allocated RAM
- 14K of Lua heap memory (reduced by 2/3)
- ~800 bytes per running script
- 144 bytes of flash