我的生产服务器返回以下错误:
MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 81 wakeup listeners added. Use emitter.setMaxListeners() to increase limit
1|pro_app | 2019-03-19 15:59:01: MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 81 wakeup listeners added. Use emitter.setMaxListeners() to increase limit
1|pro_app | at _addListener (events.js:243:17)
1|pro_app | at Connection.addListener (events.js:259:10)
1|pro_app | at Connection.Readable.on (_stream_readable.js:796:35)
1|pro_app | at Connection.once (events.js:290:8)
1|pro_app | at Connection._send (/var/www/app/node_modules/http2/lib/protocol/connection.js:355:10)
1|pro_app | at runCallback (timers.js:696:18)
1|pro_app | at tryOnImmediate (timers.js:667:5)
1|pro_app | at processImmediate (timers.js:649:5)
1|pro_app | at process.topLevelDomainCallback (domain.js:121:23)
尽管我一直在尝试通过增加以下链接中所述的侦听器数量来解决此错误:
无论侦听器的数量如何,我仍然会遇到相同的错误。
停止此错误的唯一方法是设置process.setMaxListeners(0)
,但恐怕这样做会阻止我检测到内存泄漏。
您建议只设置process.setMaxListeners(0)
吗?或者首先确保没有内存泄漏?我一直在寻找内存泄漏检测工具,但没有明确的结果。如果您对这种工具有任何建议,那肯定会有所帮助!