You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • In my case it was a lot of human readable data and thus quite verbose

    It is automatically executed when you run Modules.addCached - so your original verbose text version will no longer exist in memory. I'd check process.memory().usage and make sure you're actually freeing yourself a lot of memory and not just making your life difficult:

    This is done on a linux-based Espruino so the memory usages might be different, but you get the idea.

    >Modules.addCached("foo","/* lots and lots of text here */exports.hello = function() {};")
    =undefined
    >process.memory().usage
    =32
    >foo = require("foo")
    ={ 
      "hello": function () {}
     }
    >process.memory().usage
    =33
    >Modules.removeAllCached()
    =undefined
    >process.memory().usage   
    =32
    

    Removing the module from the cache saves just one memory block - the one with the module's name in.

About

Avatar for Gordon @Gordon started