I have been using express on node.js running on a heroku server for a simple project. When I started using new relic to monitor the memory I noticed a slow memory leak pattern. I removed all the code I developed and all other node modules and left only express itself and new relic modules. I still observe the memory leak. I was wondering if this is express.js memory leak.
我一直在heroku服务器上运行的node.js上使用express来创建一个简单的项目。当我开始使用新的遗物来监视内存时,我注意到了一个缓慢的内存泄漏模式。我删除了我开发的所有代码和所有其他节点模块,只留下了自己和新的文件模块。我仍然观察到内存泄漏。我想知道这是否是express.js内存泄漏。
Here is all the code left:
这是剩下的所有代码:
require('newrelic');
var express = require('express');
var app = express();
var env = process.env.NODE_ENV || 'development';
if ('development' == env) {
app.set('port', process.env.PORT || 3000);
}
app.get('/', function ( req, res ) {
res.send('The server is up and running!');
});
app.listen(app.get('port'), function() {
console.log('Express server listening on port %d in %s mode', app.get('port'), app.get('env'));
});
And package.json
{
"name": "memleakdebug",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.11.2",
"newrelic": "^1.16.2"
}
}
UPDATE1: Now growing memory even passed heroku's limit 512MB for free tiers. Garbage collection doesn't seem to work.
更新1:现在增长的内存甚至超过了*层的heroku限制512MB。垃圾收集似乎不起作用。
1 个解决方案
#1
10
As Lasse replied, there is a memory leak in New Relic.
正如Lasse回答的那样,New Relic中存在内存泄漏。
https://discuss.newrelic.com/t/memory-leaking-only-with-node-js-agent-installed/14448
I experimented and removed
我试验并删除了
require('newrelic');
As you can see in the image below, since I removed the New Relic agent there is no more memory leak.
正如您在下图中所看到的,因为我删除了New Relic代理,所以没有更多的内存泄漏。
#1
10
As Lasse replied, there is a memory leak in New Relic.
正如Lasse回答的那样,New Relic中存在内存泄漏。
https://discuss.newrelic.com/t/memory-leaking-only-with-node-js-agent-installed/14448
I experimented and removed
我试验并删除了
require('newrelic');
As you can see in the image below, since I removed the New Relic agent there is no more memory leak.
正如您在下图中所看到的,因为我删除了New Relic代理,所以没有更多的内存泄漏。