-
• #2
Hi - yes, it's an issue with JavaScript's handling of arrays. Since arrays can hold absolutely anything, by default they're not very memory efficient.
However if you tell Espruino what you want to put in them then you can do much better. Try:
var cmd={ On: new Float32Array([8.97,4.42 ... ]), Down: new Float32Array([8.97,4.42 ...]) etc
and you should be fine (it'll be around 8 times more efficient!). You can compact them down even more (for instance storing them in an array of bytes), but then you have to worry about scaling.
There's a bit more information about memory efficiency here: http://www.espruino.com/Performance
-
• #3
Thank you! It works! Overall memory usage is 6 times less!
Hi!
I have tried to use Puck.IR to control my LED Light strip.
After a few days of mining I have collected commands from remote control.
But when I have tried to write them to Puck, I have Out of memory.
After I have removed few commands it starts working. But nearly full memory is used.
Is it correct? How can I reduce memory usage?
Working version looks like this:
and after I send it to Puck.js process.memory() output is: