CNode

emitter.setMaxListeners 可以檢查內存泄漏?

Bbyvoid发布于14 年前最后回复14 年前1 回复5515 浏览0 收藏

文檔 http://nodejs.org/api/events.html 中寫到:

By default EventEmitters will print a warning if more than 10 listeners are added for a particular event. This is a useful default which helps finding memory leaks. Obviously not all Emitters should be limited to 10. This function allows that to be increased. Set to zero for unlimited.

其中「This is a useful default which helps finding memory leaks」。兩個問題:

1、這個東西如何檢查內存泄漏? 2、Node.js 在什麼時候會內存泄漏?

查看回复

回复 (1)

F
fish#1·14 年前

防止不小心循环监听?

不是太清楚,不过这倒是有个好处,某些不在意料之中的监听如果不听增加,可以报个警什么的

参与回复
登录后即可参与回复。登录