为什么节点需要缓存填满和泄漏 [英] Why is node require cache filling up and leaking

查看:75
本文介绍了为什么节点需要缓存填满和泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对通过Babel进行转译的环回测试API进行压力测试.但是,在这些较长的烟雾"测试中,我们发现堆分析中的需求缓存变得非常大(高达1gb),并且没有得到GCd.

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.

我了解直到删除最后一个引用之前,require cache才会出现GC,但是如果Im一遍又一遍地调用同一组方法,为什么它会继续增长?

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?

这可能是Babel 6或NodeJS 4.4.3的问题吗?

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

这是显示堆转储的屏幕截图

Here is a screen shot showing the heap dump

推荐答案

我们正在解决似乎与堆填充和用看起来像旧源代码的字符串填充服务类似的问题.问题最终成为Babel缓存(服务用户的~/.babel.json).每次重新启动该应用程序时,该文件都会增长大约2MB,并在我们的内容开始崩溃之前最终达到+ 200MB.删除文件并为服务设置以下环境变量可以解决我们的问题:BABEL_DISABLE_CACHE=1(堆从600MB减小到80MB).

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).

这篇关于为什么节点需要缓存填满和泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆