• Hi, I think in this case the issue might be that you're defining the keys inside the function. This means that the function itself is using a lot of memory (probably more so that the actual data because of the padding). You could check using E.getSizeOf(fn)

    Then, when you run that function you've got two copies of the data - one in the source and one that had just been created.

    If you defined the data in the root scope then Espruino would discard the source after executing it, leaving you with just one copy. It'll be faster too.

    You'll find that storing a few large strings (like you're doing) is probably more efficient than a small array of strings. You could save even more memory by just iterating over the array rather than joining it into a large string first too.

    Having said that, using large chunks of data like this really hammers home just how small 48kB is. Microcontrollers just have fairly limited resources, and you have to adjust your coding style to fit within their limits.

About

Avatar for Gordon @Gordon started