简体   繁体   中英

Node.js memory leak

I'm getting the following error on my node.js app. It's a simple mysql query web service. I get about 20,000 to 30,000 hits a day and it's hosted on appfog. I'm using mysql connection pooling which I think has helped. An ideas what's causing this error? After a while the app just crashes (404 error) and I have to restart it.

====> /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)

Since no source code is offered, it's really an educated guessing game, so...

at Connection.EventEmitter.addListener (events.js:175:15)
at handleDisconnect (/mnt/var/vcap.local/dea/apps/ta-0-887f6653d9e54cd272cde95a0954869b/app/app.js:75:28)

My guess is you have some code in the "handleDisconnect" function that generating your leak "addLister" by creating/binding a new event.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM