5

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.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
700 Software
  • 85,281
  • 83
  • 234
  • 341
  • Hey george, what Im doing now in order to work around the memory leak, is that I'm creating a child process for each JSDOM instance, its a colossal hack but it does the job. Another thing you could do is have a parent process watch the child's process memory and when it hits a certain limit let it restart it. – Amjad Masad May 09 '11 at 17:15
  • @Amjad: Thanks, I am already doing something similar, I am limiting the number of pages that can be parsed before the process restarts. – 700 Software May 09 '11 at 17:25

1 Answers1

1

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));
henry.oswald
  • 5,304
  • 13
  • 51
  • 73