这个函数有没有内存泄漏?

看起来好像我在下面的函数中有一个内存泄漏,因为脚本在运行时吃了大量的内存。 任何人都可以发现内存泄漏?

Base.prototype.optimize = function(configurations, data, investment, profitability, callback) { var self = this; process.stdout.write('Optimizing...'); // Exclude configurations that have already been backtested. self.removeCompletedConfigurations(configurations, function() { var configurationCompletionCount = -1; var configurationsCount = configurations.length; async.each(configurations, function(configuration, asyncCallback) { configurationCompletionCount++; process.stdout.cursorTo(13); process.stdout.write(configurationCompletionCount + ' of ' + configurationsCount + ' completed'); // Instantiate a fresh strategy. var strategy = new self.strategyFn(); // Backtest the strategy using the current configuration and the pre-built data. var results = strategy.backtest(configuration, data, investment, profitability); // Record the results. var backtest = { symbol: self.symbol, strategyName: strategy.constructor.name, configuration: configuration, profitLoss: results.profitLoss, winCount: results.winCount, loseCount: results.loseCount, tradeCount: results.winCount + results.loseCount, winRate: results.winRate }; Backtest.collection.insert(backtest, function(error) { // Ensure memory is freed. strategy = null; results = null; backtest = null; asyncCallback(error); }); }, function(error) { if (error) { console.log(error.message || error); } process.stdout.cursorTo(13); process.stdout.write(configurationsCount + ' of ' + configurationsCount + ' completed\n'); callback(); }); }); }; 

而修复它的指针会很棒!

我猜测async.each在复制上工作,而不是实际的对象。 所以多个副本可能会导致内存泄漏。