Loading on demand is fine, but require() loads the code as a module, so all of the module gets cached (in case you use it a second time) and you have to manually clear it with Modules.removeCached(...).
If you just load it with new Function(..) or eval then when the function is done executing, all the variables referenced by it will get freed.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Loading on demand is fine, but
require()
loads the code as a module, so all of the module gets cached (in case you use it a second time) and you have to manually clear it withModules.removeCached(...)
.If you just load it with
new Function(..)
oreval
then when the function is done executing, all the variables referenced by it will get freed.