When I used jsdom with Node.js to scrape tens of thousands of web pages, an out of memory error occurred.
FATAL ERROR: CALL_AND_RETRY_2 Allocation failed - process out of memory
It seems you need to call the window.close() method to free memory associated with the window object used in the callback method passed to the jsdom.env method.
jsdom.env(html, function (errors, window) {
// free memory associated with the window
window.close();
});
I really felt the pain of not using it exactly as written in the documentation…
・jsdom and node.js leaking memory - Stack Overflow
・javascript - Memory leak in Node.js scraper - Stack Overflow
That’s all from the Gemba.