Quantcast
Viewing all articles
Browse latest Browse all 8068

Android Ti.Network.createHTTPClient memory leak

I have created a background service that every second has to ask to the server if there are any new data. Using debug monitor what I notice is that the allocated memory is growing and growing till it says memory leak.

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();
What I have realized so far is fault of xhr.send(), it does not get clean or maybe it's me doing something wrong. Can anyone suggest, how to avoid this memory leak?

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>