luaqrcode icon indicating copy to clipboard operation
luaqrcode copied to clipboard

Reduce RAM usage

Open pierluigizagaria opened this issue 1 year ago • 4 comments

Thank you for providing this lib to the community. I'm trying to use this library into a RC remote controller that uses lua script. It complains for the RAM usage.

Is there any way to reduce RAM usage?

pierluigizagaria avatar Apr 24 '24 18:04 pierluigizagaria

I have no idea how to reduce RAM usage. I use this library on a laptop with plenty RAM so I have never had the need to look at that.

pgundlach avatar Apr 24 '24 19:04 pgundlach

The big arrays are the one that occupies ram. Could you simplify the qr code generation by removing advanced options? Or maybe by removing the big declared tables?

pierluigizagaria avatar Apr 24 '24 21:04 pierluigizagaria

How much size do the arrays take? I assume that the cclxvi table takes up most space and can be calculated on the fly. The other tables? I am not really sure how to calculate those.

pgundlach avatar Apr 25 '24 05:04 pgundlach

FYI: I've done the optimization and created an EdgeTX script based on this lib: https://github.com/alufers/edgetx-gps-qrcode

Here are is the outline of the modifications I had to make to make it run on the STM32 embedded in my radio: https://github.com/alufers/edgetx-gps-qrcode/blob/master/gps_qr.src.lua#L9

TL;DR: I had to remove almost everything not used for generating a binary QR code with the L error correction, and code-golf it to minimize the RAM usage. Additionally I run the script through a minifier.

The modifications remove useful features, so I would not want to contribute them here.

alufers avatar May 28 '24 16:05 alufers

Thank you very much @alufers for the work! I'll close this issue, since your changes do not go back into this repository

pgundlach avatar Nov 28 '25 16:11 pgundlach