node.js - NodeJS Memory Leak when using VM to execute untrusted code -


I am using nodjs to run unreliable code safely. I have seen a huge memory leak which takes about 10 mm of memory on every execution and does not release it. After all, my node process ends up using 500M + memory. After some excavation, I saw the problem in continuous construction of VM. To test my theory, I commented on the code that creates VMs, of course, the memory usage dropped dramatically, I re-dismissed the code again and got global.gc () strategic around problem areas Appeared and divided the node with Exposure -GC flag. It dramatically reduced my memory usage and retains functionality.

Is there a better way to clean VMS that I am using it?

My next approach is the cache which is the vm with the unsafe code and it is reusing it if I see the unsafe code again (background: I Parsing functions, thus, the unsafe code is often executed or executed once

some reference code.

  async.each (item , Function (i, cb) {// initial reference ... var Reference = Vm.createContext (init); // Captivated untrusted code work executed = vm.runInContext (pars, context); // This dramatically improves usage, but standard API / // global.gc Return results through a callback CB (tap, capped);};    

When I see this right, see this v5.9.0 , It appears that in both cases, both the node core patrons and The same programmer Many can do that - we have to wait for the upstream fix in the v8 .

No, you can not do anything about it. This bug was good though catching!

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -