每当我运行以下代码时,我都会收到错误
(node) warning: possible EventEmitter memory leak detected. 11 message listeners added. Use emitter.setMaxListeners() to increase limit.
代码:
function compute() {
var PythonShell = require('python-shell');
var options = {
scriptPath: '/home/pi/projectFinal/nodejsControllingServo/sensorTest'
};
var pyshell = new PythonShell('sensor.py',options);
var eventsEmitter = require("events").EventEmitter;
pyshell.on('message', function (message) {
myValueList [counter] = message;
counter=counter+1;
});
pyshell.end(function (err) {
if (err) throw err;
for ( var i = 4; i < myValueList.length; i++) {
console.log ("My value : " + myValueList[i]);
});
sleep.usleep(5000);
process.nextTick(compute);
}
compute();
什么是可能的解决方案,以便我可以摆脱内存泄漏? 提前致谢