[英](node:125008) MaxListenersExceededWarning: Possible EventEmitter memory leak detected
(node:125008) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. (节点:125008)MaxListenersExceededWarning:检测到可能的 EventEmitter 内存泄漏。 11 ready listeners added.
添加了 11 个准备好的侦听器。 Use emitter.setMaxListeners() to increase limit
使用emitter.setMaxListeners() 增加限制
How exactly do I increase the number of listener events?我究竟如何增加侦听器事件的数量? I've searched around and none of the methods I've tried have worked : (
我四处搜索,但我尝试过的方法都没有奏效:(
11 ready listeners added 添加了11个就绪的侦听器
means you have 11 <Discord.client>.on('ready', <function>)
表示您有11个
<Discord.client>.on('ready', <function>)
so node.js warns you because that uses a lot of memory. 所以node.js警告您,因为这会占用大量内存。 You probably have nested events somewhere so it makes 11 ready events.
您可能在某处嵌套了事件,因此它使11个就绪事件成为可能。
This is explained in the manual: http://nodejs.org/docs/latest/api/events.html#events_emitter_setmaxlisteners_n 手册对此进行了说明: http : //nodejs.org/docs/latest/api/events.html#events_emitter_setmaxlisteners_n
What version of Node is this? 这是哪个版本的Node? What other code do you have?
您还有什么其他代码? That isn't normal behavior.
那不是正常行为。
In short, its: process.setMaxListeners(0);
简而言之,它是:
process.setMaxListeners(0);
Also see: node.js - request - How to “emitter.setMaxListeners()”? 另请参阅: node.js-请求-如何“ emitter.setMaxListeners()”?
I'd like to point out here that that warning is there for a reason and there's a good chance the right fix is not increasing the limit but figuring out why you're adding so many listeners to the same event. 我想在此指出警告的出现是有原因的,正确的解决方法很有可能不会增加限制,而是要弄清楚为什么要在同一事件中添加如此多的侦听器。 Only increase the limit if you know why so many listeners are being added and are confident it's what you really want.
仅当您知道为什么要添加如此多的侦听器并确信这是您真正想要的时,才增加限制。
I found this page because I got this warning and in my case there was a bug in some code I was using that was turning the global object into an EventEmitter! 我找到此页面是因为收到此警告,并且在我的情况下,我正在使用的某些代码中存在一个错误,该错误将全局对象转换为EventEmitter! I'd certainly advise against increasing the limit globally because you don't want these things to go unnoticed.
我当然建议不要在全球范围内增加限制,因为您不希望这些事情被忽视。
I resolved with this line:我用这一行解决了:
process.setMaxListeners(Infinity); process.setMaxListeners(Infinity);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.