Using Async : import fails

Posted on
  • Hello,

    I wish to use the Async library, because it would save me a lot of time... I got the last version of the library from http://caolan.github.io/async/index.html­ . The minified and the non minified files are placed in the modules directory.
    The target is Espruino Pico V1.86.
    I reset() the target and then import with this code :

    var async = require("async");
    

    The import fails and returns:

    >echo(0);
    ERROR: Out of Memory!
    in function called from line 1 col 20814
    ...lectSeries=t,a.wrapSync=E;}));
                                  ^
    =undefined
    > 
    

    The minified file is 20816 bytes (so it should get into memory ?).
    It seems that some other Espruino users managed to use Async on Espruino.

    Any clue and advice is welcome.

    GeekBot

  • It's possible that other users were using an older, smaller version of async?

    Also, maybe try putting var async = require('async') as the first line in the file.

    Problem is, when you upload a module, it actually needs 3x the amount of memory to load it in. First it comes it via the input buffer, then the string has to get parsed, then finally loaded into memory. It means that realistically your 21k needs 63k of memory to load in (even if it only uses 21k once loaded), which is more than the Pico has available.

    If you desperately need it, I'd consider stripping out async functions you're not going to use. Personally I'd try to avoid using it though - I think the time it saves will be wasted again trying to fit the rest of your code into the remaining memory.

  • Thank you Gordon, I didn't know the amount of requested memory. I will write some basic primitives instead of using Async.
    Best regards
    GeekBot

  • @GeekBot - try this small Async.js helper, uploaded by Thorsten von Eicken

  • Thank you MaBe, looks very interesting, I will test it.
    Best regards
    GeekBot

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Using Async : import fails

Posted by Avatar for GeekBot @GeekBot

Actions