Why is node require cache filling up and leaking

萝らか妹 提交于 2019-12-23 13:12:21

问题


Im stress testing an API in loopback which is transpiled with Babel. However, during these longer "smoke" tests, we have seen the require cache in Heap analysis growing quite large (up to 1gb) and does not get GCd.

I understand the require cache wont GC until the last reference is removed, but why would it continue to grow if Im calling the same set of methods over and over?

Could this be an issue with Babel 6, or NodeJS 4.4.3?

Here is a screen shot showing the heap dump


回答1:


We were hitting what appeared to be a similar issue with the heap filling and filling with strings that looked like old source code the service. The problem ended up being the Babel cache (~/.babel.json for the service's user). This file was growing by about 2MB for every restart of the app and eventually hit +200MB before our stuff started breaking. Removing the file and setting the following env var for the service solved our problem: BABEL_DISABLE_CACHE=1 (heap went from 600MB down to 80MB).



来源:https://stackoverflow.com/questions/36628540/why-is-node-require-cache-filling-up-and-leaking

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!