Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to destroy a context?

There is a memory leak in Node.JS or in V8 that removes my ability to re-use a process to jqueryify many HTML pages.

The bug is here: https://github.com/joyent/node/issues/1007

Bug meanwhile, is it possible to "destroy" a context when I am done with it? That seams like it might make for a simple hack to the jsdom code so I can move write my own code in a logical manner without writing the restarts.

We have a way to keep track of our company's own tweaks to Open Source projects so we can bring in updates and still fix bugs we may have found without waiting for the Open Source community.

If I can destroy the context, I think I will be good to go.

tmpvar at jsdom says this is a Node.JS issue and I don't know when it will be fixed because see this is months old and there are already many open issues https://github.com/joyent/node/issues/637.

like image 242
700 Software Avatar asked Nov 13 '22 23:11

700 Software


1 Answers

The best way I can think of is to look at using the node VM stuff.

vm.runInNewContext might be of use as you get access to the returned context do with as you wish.

var util = require('util'),
    vm = require('vm'),
    sandbox = {
      animal: 'cat',
      count: 2
    };

vm.runInNewContext('count += 1; name = "kitty"', sandbox, 'myfile.vm');
console.log(util.inspect(sandbox));
like image 95
henry.oswald Avatar answered Nov 16 '22 17:11

henry.oswald