1
我創建了一個後臺服務,如果有任何新數據,每秒都必須向服務器請求。使用調試監視器,我注意到分配的內存正在增長並增長,直到它說內存泄漏。Android Ti.Network.createHTTPClient內存泄漏
index.js
var intent = Titanium.Android.createServiceIntent({
url: 'service.js'
});
intent.putExtra('interval', 1000); // Needs to be milliseconds
Titanium.Android.startService(intent);
service.js
var URL = "localhost:8051";
Ti.API.info("checkForNotification: " + URL);
var xhr = Ti.Network.createHTTPClient({
onload: function(e) {
Ti.API.info('onload called, HTTP status = '+this.status);
},
onerror: function(e) {
Ti.API.info('error, HTTP status = '+this.status);
},
timeout:5000 /* in milliseconds */
});
xhr.open('GET', URL);
xhr.send();
我迄今實現是xhr.send(),它沒有得到乾淨的錯也許是我做的事情錯誤。 任何人都可以建議,如何避免這種內存泄漏?