[英]Node.js memory leak
我在node.js应用程序上收到以下错误。 这是一个简单的mysql查询Web服务。 我每天大约有20,000到30,000次点击,它是在appfog上托管的。 我正在使用我认为有帮助的mysql连接池。 是什么导致了这个错误? 一段时间后,应用程序崩溃(404错误),我必须重新启动它。
====> /logs/staging.log <====
# Logfile created on 2013-02-06 06:56:31 +0000 by logger.rb/25413
Installing dependencies. Node version 0.8.14
Installing mysql@mysql@2.0.0-alpha7 from local path
Installing require-all@require-all@0.0.3 from local path
Installing bignumber.js@bignumber.js@1.0.1 from local path
Installing require-all@https://registry.npmjs.org/require-all/-/require-all-0.0.5.tgz from local path
Installing request@request@ from local path
Installing form-data@form-data from local path
Installing combined-stream@combined-stream@0.0.3 from local path
Installing delayed-stream@delayed-stream@0.0.5 from local path
Installing async@async@0.1.9 from local path
Installing mime@mime from local path
====> /logs/stderr.log <====
(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
at Connection.EventEmitter.addListener (events.js:175:15)
at handleDisconnect (/mnt/var/vcap.local/dea/apps/ta-0-887f6653d9e54cd272cde95a0954869b/app/app.js:75:28)
at /mnt/var/vcap.local/dea/apps/ta-0-887f6653d9e54cd272cde95a0954869b/app/app.js:93:13
at Pool.getConnection (/mnt/var/vcap.local/dea/apps/ta-0-887f6653d9e54cd272cde95a0954869b/app/node_modules/mysql/lib/Pool.js:25:5)
at QueryDB (/mnt/var/vcap.local/dea/apps/ta-0-887f6653d9e54cd272cde95a0954869b/app/app.js:73:14)
at IncomingMessage.http.createServer.pool.getConnection.connection.on.offset (/mnt/var/vcap.local/dea/apps/ta-0-887f6653d9e54cd272cde95a0954869b/app/app.js:51:17)
at IncomingMessage.EventEmitter.emit (events.js:93:17)
at IncomingMessage._emitEnd (http.js:366:10)
at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:149:23)
at Socket.socket.ondata (http.js:1704:22)
(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
at Connection.EventEmitter.addListener (events.js:175:15)
at handleDisconnect (/mnt/var/vcap.local/dea/apps/ta-0-887f6653d9e54cd272cde95a0954869b/app/app.js:75:28)
at /mnt/var/vcap.local/dea/apps/ta-0-887f6653d9e54cd272cde95a0954869b/app/app.js:93:13
at Pool.getConnection (/mnt/var/vcap.local/dea/apps/ta-0-887f6653d9e54cd272cde95a0954869b/app/node_modules/mysql/lib/Pool.js:25:5)
at QueryDB (/mnt/var/vcap.local/dea/apps/ta-0-887f6653d9e54cd272cde95a0954869b/app/app.js:73:14)
at IncomingMessage.http.createServer.pool.getConnection.connection.on.offset (/mnt/var/vcap.local/dea/apps/ta-0-887f6653d9e54cd272cde95a0954869b/app/app.js:51:17)
at IncomingMessage.EventEmitter.emit (events.js:93:17)
at IncomingMessage._emitEnd (http.js:366:10)
at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:149:23)
at Socket.socket.ondata (http.js:1704:22)
====> /logs/stdout.log <====
Wed, 06 Feb 2013 07:27:13
Error: Connection lost: The server closed the connection.
at Protocol.end (/mnt/var/vcap.local/dea/apps/ta-0-887f6653d9e54cd272cde95a0954869b/app/node_modules/mysql/lib/protocol/Protocol.js:72:13)
at Socket.onend (stream.js:66:10)
at Socket.EventEmitter.emit (events.js:126:20)
at TCP.onread (net.js:417:51)
Wed, 06 Feb 2013 07:34:51
Error: Connection lost: The server closed the connection.
at Protocol.end (/mnt/var/vcap.local/dea/apps/ta-0-887f6653d9e54cd272cde95a0954869b/app/node_modules/mysql/lib/protocol/Protocol.js:72:13)
at Socket.onend (stream.js:66:10)
at Socket.EventEmitter.emit (events.js:126:20)
at TCP.onread (net.js:417:51)
Wed, 06 Feb 2013 07:34:51
Error: Connection lost: The server closed the connection.
at Protocol.end (/mnt/var/vcap.local/dea/apps/ta-0-887f6653d9e54cd272cde95a0954869b/app/node_modules/mysql/lib/protocol/Protocol.js:72:13)
at Socket.onend (stream.js:66:10)
at Socket.EventEmitter.emit (events.js:126:20)
at TCP.onread (net.js:417:51)
Wed, 06 Feb 2013 07:39:14
Error: Connection lost: The server closed the connection.
at Protocol.end (/mnt/var/vcap.local/dea/apps/ta-0-887f6653d9e54cd272cde95a0954869b/app/node_modules/mysql/lib/protocol/Protocol.js:72:13)
at Socket.onend (stream.js:66:10)
at Socket.EventEmitter.emit (events.js:126:20)
at TCP.onread (net.js:417:51)
Wed, 06 Feb 2013 07:39:14
Error: Connection lost: The server closed the connection.
at Protocol.end (/mnt/var/vcap.local/dea/apps/ta-0-887f6653d9e54cd272cde95a0954869b/app/node_modules/mysql/lib/protocol/Protocol.js:72:13)
at Socket.onend (stream.js:66:10)
at Socket.EventEmitter.emit (events.js:126:20)
at TCP.onread (net.js:417:51)
Wed, 06 Feb 2013 07:41:08
Error: Connection lost: The server closed the connection.
at Protocol.end (/mnt/var/vcap.local/dea/apps/ta-0-887f6653d9e54cd272cde95a0954869b/app/node_modules/mysql/lib/protocol/Protocol.js:72:13)
at Socket.onend (stream.js:66:10)
at Socket.EventEmitter.emit (events.js:126:20)
at TCP.onread (net.js:417:51)
Wed, 06 Feb 2013 07:41:08
Error: Connection lost: The server closed the connection.
at Protocol.end (/mnt/var/vcap.local/dea/apps/ta-0-887f6653d9e54cd272cde95a0954869b/app/node_modules/mysql/lib/protocol/Protocol.js:72:13)
at Socket.onend (stream.js:66:10)
at Socket.EventEmitter.emit (events.js:126:20)
at TCP.onread (net.js:417:51)
Wed, 06 Feb 2013 07:43:35
Error: Connection lost: The server closed the connection.
at Protocol.end (/mnt/var/vcap.local/dea/apps/ta-0-887f6653d9e54cd272cde95a0954869b/app/node_modules/mysql/lib/protocol/Protocol.js:72:13)
at Socket.onend (stream.js:66:10)
at Socket.EventEmitter.emit (events.js:126:20)
at TCP.onread (net.js:417:51)
Wed, 06 Feb 2013 07:45:10
Error: Connection lost: The server closed the connection.
at Protocol.end (/mnt/var/vcap.local/dea/apps/ta-0-887f6653d9e54cd272cde95a0954869b/app/node_modules/mysql/lib/protocol/Protocol.js:72:13)
at Socket.onend (stream.js:66:10)
at Socket.EventEmitter.emit (events.js:126:20)
at TCP.onread (net.js:417:51)
Wed, 06 Feb 2013 07:47:22
Error: Connection lost: The server closed the connection.
at Protocol.end (/mnt/var/vcap.local/dea/apps/ta-0-887f6653d9e54cd272cde95a0954869b/app/node_modules/mysql/lib/protocol/Protocol.js:72:13)
at Socket.onend (stream.js:66:10)
at Socket.EventEmitter.emit (events.js:126:20)
at TCP.onread (net.js:417:51)
Wed, 06 Feb 2013 07:47:22
Error: Connection lost: The server closed the connection.
at Protocol.end (/mnt/var/vcap.local/dea/apps/ta-0-887f6653d9e54cd272cde95a0954869b/app/node_modules/mysql/lib/protocol/Protocol.js:72:13)
at Socket.onend (stream.js:66:10)
at Socket.EventEmitter.emit (events.js:126:20)
at TCP.onread (net.js:417:51)
由于没有提供源代码,它真的是一个有教育的猜谜游戏,所以......
at Connection.EventEmitter.addListener (events.js:175:15)
at handleDisconnect (/mnt/var/vcap.local/dea/apps/ta-0-887f6653d9e54cd272cde95a0954869b/app/app.js:75:28)
我的猜测是你在“handleDisconnect”函数中有一些代码通过创建/绑定一个新事件来生成泄漏“addLister”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.