diff --git a/CHANGELOG.yaml b/CHANGELOG.yaml index 041884fc..959ab032 100644 --- a/CHANGELOG.yaml +++ b/CHANGELOG.yaml @@ -1,4 +1,6 @@ unreleased: + fixed bugs: + - GH-711 Fixed an issue where boot code was not being garbage collected chores: - GH-710 Refactor worker interface to be node alike diff --git a/lib/bridge.js b/lib/bridge.js index 39655e86..de3b5ac3 100644 --- a/lib/bridge.js +++ b/lib/bridge.js @@ -67,6 +67,7 @@ module.exports = function (bridge, options, callback) { firmwareCode; const id = UVM_ID_ + randomNumber(), + { bootCode, debug, bootTimeout, _sandbox } = options, // function to forward messages emitted forwardEmits = (e) => { @@ -105,7 +106,7 @@ module.exports = function (bridge, options, callback) { worker.off(EXIT, forwardExit); - (options._sandbox ? Promise.resolve() : worker.terminate()) + (_sandbox ? Promise.resolve() : worker.terminate()) .then(() => { callback(); }); worker = null; }; @@ -131,18 +132,18 @@ module.exports = function (bridge, options, callback) { }); // get firmware code string with boot code - firmwareCode = sandboxFirmware(options.bootCode, id, options.debug); + firmwareCode = sandboxFirmware(bootCode, id, debug); // start boot timer, stops once we get the load signal, terminate otherwise bootTimer = setTimeout(() => { terminateWorker(); - callback(new Error(`uvm: boot timed out after ${options.bootTimeout}ms.`)); - }, options.bootTimeout); + callback(new Error(`uvm: boot timed out after ${bootTimeout}ms.`)); + }, bootTimeout); // if sandbox worker is provided, we simply need to init with firmware code // @todo validate sandbox type or APIs - if (options._sandbox) { - worker = options._sandbox; + if (_sandbox) { + worker = _sandbox; // add event listener methods for Web worker /* istanbul ignore next-line */ diff --git a/test/benchmark/memory-footprint.test.js b/test/benchmark/memory-footprint.test.js new file mode 100644 index 00000000..57d8cec7 --- /dev/null +++ b/test/benchmark/memory-footprint.test.js @@ -0,0 +1,10 @@ + +// TODO: Implement this test +// v8.getHeapStatistics() can be used to measure memory +// footprint but the results from it are not consistent with +// values from heap snapshots created manually in Chrome DevTools. +describe.skip('memory footprint', function () { + it('should not increase memory footprint significantly', function (done) { + done(); + }); +});