Possible memory leak in v4 on node v6 #2997
Comments
|
Thanks for the report, we will take a look! Express 4.x does not yet support Node.js 6.0, so it's not a high priority, but we will certainly take a look when possible. If you have any suggested fixes or what the problem is, that would help tremendously! Looking at the stack, I don't think that is an exception from a OOM condition, but rather a failed assertion from within C++. |
|
Because of the way Express catches your exception, I would no say the two example are equivalent. Can you also try with the following Node.js example to see if under your load, it still works? var http = require('http')
var server = http.createServer(function (req, res) {
try {
throw new Error('test')
} catch (e) {
res.statusCode = 500
res.write(e.stack)
res.end()
}
})
server.listen(3000, function () {
console.log('listening on port 3000')
}) |
haha, I didn't scroll al the way to the right on the GC messages, my bad :) |
|
@lykkin can you say which specific point version you were testing under (just pick one if it was multiple) so we can focus on testing on the same Node.js build you were running on? |
|
@dougwilson i tested this under 4.13.4, as well as the latest patch versions down to 4.9.8 running with your provided code example there is no memory growth |
|
I'm looking for the version of Node.js |
|
ah, sorry. tested on 6.1.0 and 6.0.0 |
|
Thanks! I'll try to take a look sometime in the next few weeks, unless someone can get to it before me :) If you can provide some insights into the cause as well, that would be much appreciated! If it helps anyone who wants to investigate, these are the things I would look into:
|
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. |
|
Hi @rzk, historically we have tried to actually vet Express and it's code on a new major version of Node.js/io.js in order to support that version. This is not to say that Express won't work on the version, but until we vet we, we honestly cannot say if it fully functions, if there are any "gotchas", etc. I just wanted to make it clear, because you never know what will happening when you jump to a new runtime, especially in production. There may be a slow memory leak, and change in an API that introduces a security vulnerability, etc. For the past few weeks, I have been combing through Node.js 6.x and the Express code base (this is many dozens on modules, not just the code in this repository) to check that everything is working on Node.js 6.x as expected. We have various modules that have to shim Node.js to add missing API pieces, which are the most likely things to break down on a major upgrade, since they have certain expectations of what the Node.js source code look like.
I'm not saying that, only that you are definitely leading the pack and that as you find issues, please report them back, like this issue has done, so we can investigate along with the current Node.js 6.x support investigation. @rzk, since you are using Node.js 6.x, you may very well be encountering this memory leak that is reported, especially since the reported reproduction is so simple. Would you be able to help us diagnose the issue, please? Anyone else in the Express group can also help out, but I have not heard from anyone, so I don't think anyone is actively looking into this issue, and I am working on a security issue that needs to be released, which is why this is not a high priority (the security release is). |
|
@lykkin can you share your OS and machine specs, and the exact procedure to reproduce and observe the behavior? And does the app crash? I tested Express 4.13.1 with Node.js 4.4.4, and 6.1.0 on my 3.2 GHz Mac with 8 GB of RAM. The behavior is largely similar for 4.4.4 and 6.1.0; both start at 16MB and climb to ~21MB and stay there during the period of observation. I used This makes 30 concurrent requests to the app for 5 seconds, with a delay of 1 second for each user. The observation is made using |
|
@hacksparrow Sure, I'm running on a 2.5 GHz mac with 16 GB of RAM running OSX 10.10. I'm running the code snippet above on node 6.1.0 and express 4.13.4. I noticed that when the load increases the speed of memory growth also increases. Using gobench to apply load ( I am monitoring memory usage of the process using |
|
Thanks for the details @lykkin, I will review again. |
|
I can now observe the RAM consumption growing drastically and CPU usage shooting up to 100% too. We will look further into this issue. Thanks for reporting, @lykkin. |
|
Hi @hacksparrow, have you figured anything out? I cannot find any actual memory leak so far. I took the example app, ran it on Node.js 6.1.0 and pounded it with requests for 3 days and it's still hovering around 100 MB RSS. If there was a memory leak, you'd think that it would trigger, no matter how slowly? I have not tried to look at what it would take to run |
|
Also, @lykkin @hacksparrow, if one of you have time, you can add the command line argument |
|
@dougwilson nothing yet, let me add |
|
So |
|
It indeed seems to be because of the Error objects holding the stack frames. @dougwilson @lykkin maybe we can close this now? |
|
I'm ok with closing this since it isn't something happening in express causing it. Thanks for looking into it, though! |
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.
This doesn't occur in node v4.x.
I wrote something similar using the http module, which doesn't exhibit this behavior:
The text was updated successfully, but these errors were encountered: