我正在使用PouchDB構建應用程序並遇到此錯誤。我剛開始使用Pouch,社區在幫助我更好地理解並回答我的問題方面表現出色。PouchDB引發「可能發生EventEmitter內存泄漏」警告
應用程序從PouchDB加載文檔,然後定期保存它。約6或7節省後,我在控制檯中得到以下錯誤。
(node) warning: possible EventEmitter memory leak detected. 11 listeners added.
Use emitter.setMaxListeners() to increase limit.
console.trace()
87.EventEmitter.addListener @ pouchdb.js:11140setUpEventEmitter @ pouchdb.js:
1044781.PouchDB.defaults @ pouchdb.js:
10583(anonymous function) @ eval.js:10
1../postmessagerpc.js @ eval.js:52
s @ eval.js:1e @ eval.js:1
(anonymous function) @ eval.js:1
現在,http://pouchdb.com/errors.html#event_emitter_limit考慮看看我看到下面的標註:
這可能表明代碼中的內存泄漏。如果您經常啓動和停止這些事件,請檢查以確保您正在對任何更改(),replicate()或sync()處理程序調用cancel()。
我檢索與我的服務下面的代碼記錄:
obj.save = function (doc) {
return localDB.put(doc).then(function (response) {
return response;
}).catch(function (err) {
$log.error(err);
return false;
});
};
:
obj.get = function (uuid) {
return localDB.get(uuid).then(function (response) {
//$log.info(response);
return response;
});
};
,然後點擊一個按鈕,當我用我的服務以下保存文檔
我對此沒有足夠的瞭解,無法確切地說明它發生的原因。根據文件,我認爲這隻會出現在.on()
,'.changes()
,.sync()
或.replicate()
。
是否有可能發生內存泄漏?爲什麼要保存文件導致發射器?
感謝。我只是做得到和放。沒有發生什麼瘋狂的事情,但現在你提出這個問題,我也使用角袋,所以也許這是罪魁禍首。它是一個非常簡單的代碼(只有89行),但我確實看到'.on()'引用。 https://github.com/angular-pouchdb/angular-pouchdb/blob/master/angular-pouchdb.js – kisonay