I've got a scenario where I need to poll a service every 30 seconds with a GET request and store it for the UI to display. I've wrapped my GET request in a setInterval w/ 30000ms. What I'm seeing is that after every call in the browser, the mem climbs between 100k and 200k. After about 8mb or so, the browser properly garbage collects and the mem falls back down by 4-5mb.
My problem is that with this application wrapped in Cordova 6.5, the memory climbs for about 4 days before the app crashes. The logs from the crash show issues related to memory running out. I've also examined the running application with xCode and notice the same memory climb as I see in a browser, which never gets collected. I'm inclined to think that there is some issue with garbage collection of an Observable that is instantiated within a setInterval call.
I've created a plunkr that shows the memory climb. Looking for 1) why this is happening, and 2) how to rectify it without having to destroy the view and reload it (which is what I've resorted to for the time being).
setInterval(() => {
this.http.get('./people.json')
.subscribe((response) => {
this.people = response;
}, (err) => {
//console.log('Error');
});
}, 15000);
Environment: Angular 4.0.0 / RxJS 5.2.0 / @angular/http 4.0.0 / Cordova 6.5 / iOS 10.3