Possible memory leak in v4 on node v6

Using the example code below on express v4.x and node v6.x causes the process to OOM when put under load. The server was put under ~30 requests/sec.

var express = require('express');
var app = express();
app.get('/', function (req, res) { 
  throw new Error('hello')
});
app.listen(3000, function () {console.log('done')});
<--- Last few GCs --->

  120821 ms: Mark-sweep 1206.8 (1435.0) -> 1197.9 (1435.0) MB, 142.4 / 0 ms [allocation failure] [GC in old space requested].
  120990 ms: Mark-sweep 1197.9 (1435.0) -> 1197.9 (1435.0) MB, 169.1 / 0 ms [allocation failure] [GC in old space requested].
  121157 ms: Mark-sweep 1197.9 (1435.0) -> 1197.9 (1435.0) MB, 166.3 / 0 ms [last resort gc].
  121326 ms: Mark-sweep 1197.9 (1435.0) -> 1197.8 (1435.0) MB, 168.9 / 0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x18640e7c9fa9 <JS Object>
    1: isToplevel(aka CallSiteIsToplevel) [native messages.js:~369] [pc=0x3553d6016245] (this=0x27b340215d89 <a CallSite with map 0x1f2a45e2b2f9>)
    2: toString(aka CallSiteToString) [native messages.js:~403] [pc=0x3553d601cf09] (this=0x27b340215d89 <a CallSite with map 0x1f2a45e2b2f9>)
    3: FormatStackTrace [native messages.js:561] [pc=0x3553d5f6ca41] (this=0x18640e7e81c1 <JS Global Object...

FATAAbort trap: 6

This doesn’t occur in node v4.x.

I wrote something similar using the http module, which doesn’t exhibit this behavior:

var http = require('http')

process.on('uncaughtException', function (e) {console.log(e)})

var server = http.createServer(function (req, res) {
  throw new Error('test')
})

server.listen(3000, function () {
  console.log('listening on port 3000')
})

Author: Fantashit

1 thought on “Possible memory leak in v4 on node v6

  1. Express 4.x does not yet support Node.js 6.0, so it’s not a high priority

    wait, what? where this is stated? (apart from travis config)

    I’ve been writing all my express apps using newer versions of node using es6 features that you can check out at http://node.green/ (without –harmony) and now you are saying that I need to revert back to something like 4.4.2 and that that is not high priority?

    I feel like I’m not alone in this boat.

Comments are closed.