Memory leaks in 3.4.0 and later versions
each request will be an instance of new Meter.js
Call chain
- node_modules/@pm2/io/build/main/index.js
const pmx_1 = require("./pmx");
const IO_KEY = Symbol.for('@pm2/io');
const isAlreadyHere = (Object.getOwnPropertySymbols(global).indexOf(IO_KEY) > -1);
- node_modules/@pm2/io/build/main/pmx.js
this.actionService.init();
serviceManager_1.ServiceManager.set('actions', this.actionService);
this.metricService = new metrics_1.MetricService();
- node_modules/@pm2/io/build/main/metrics/httpMetrics.js
hookRequire() {
this.hooks = requireMiddle(['http', 'https'], (exports, name) => {
this.hookHttp(exports, name);
return exports;
});
}
if (event !== 'request')
return original.apply(this, arguments);
if (name === 'http') {
self.registerHttpMetric();
}
- node_modules/@pm2/io/build/main/utils/metrics/meter.js
this._interval = setInterval(function () {
self._rate.tick();
}, this._tickInterval);
this._interval.unref();
Simple test case
//test.js
const http = require('http');
http.createServer(function(req, res){
res.end('okay');
}).listen(8080)
1、run by ./node_modules/.bin/pm2-dev start ./test.js
2、request http://127.0.0.1:8080
as the amount of requests increases, the cpu will eventually skyrocket and memory leaks
Memory leaks in 3.4.0 and later versions
each request will be an instance of new Meter.js
Call chain
Simple test case
1、run by
./node_modules/.bin/pm2-dev start ./test.js2、request
http://127.0.0.1:8080as the amount of requests increases, the cpu will eventually skyrocket and memory leaks