Memory leak in Node.js scraper

前端 未结 4 1911
小鲜肉
小鲜肉 2021-02-04 13:23

This is a simple scraper written in JavaScript with Node.js, for scraping Wikipedia for periodic table element data. The dependencies are jsdom for DOM manipulation and chain-ga

4条回答
  •  轮回少年
    2021-02-04 14:10

    jsdom does have a memory leak which stems from the copy in and copy out logic behind node's vm.runInContext(). There has been effort to fix this problem using c++ and we are hoping to prove out the solution before attempting to push it into node.

    A workaround for now is to spawn up a child process for each dom and close it down when you are done.

    EDIT:

    as of jsdom 0.2.3 this issue is fixed as long as you close the window (window.close()) when you are done with it.

提交回复
热议问题