DEPRECATED-mapbox-ios-sdk icon indicating copy to clipboard operation
DEPRECATED-mapbox-ios-sdk copied to clipboard

Background caching memory growth

Open bilby91 opened this issue 9 years ago • 10 comments

Hello,

I'm running some issues with the background caching API.

I'm trying to cache multiple tileSources. After each tileSource finishes caching I start the new one. A lot of memory is allocated during the caching of one tileSource but most of the memory never gets deallocated.

After caching 3 tileSource (5000 tiles each ) I run out of memory.

Any suggestion on where the issue could be ? I can dig up anywhere but need some help.

bilby91 avatar Mar 06 '15 19:03 bilby91

After debugging I think that the issue only happens when I try to cache RMBingSource. Also, this tile source needs to make a request to find the actual tile URL.

bilby91 avatar Mar 11 '15 20:03 bilby91

I can confirm that I have the same problem using tiles served from Mapbox's servers. Downloading 7K tiles consumes over 200 MB of memory. The bigger problem is that the memory doesn't get released after the download completes. I'd love to enable my app users to download about 15K tiles since it would improve the user experience but I current limit it to avoid app crashes. Downloading 15K tiles worked just fine prior to iOS8 but has been broken since then. I spent about 80 hours working with Justin from Mapbox on the problem but we never found a solution. I'm hoping they will get to the bottom of it some day.

elemprod avatar Mar 13 '15 20:03 elemprod

Found the problem. NSURLConnection is leaking. Try using NSURLSession. I'm working on a PR for next weak. On vie, 13 mar 2015 at 17:38 elemprod [email protected] wrote:

I can confirm that I have the same problem using tiles served from Mapbox's servers. Downloading 7K tiles consumes over 200 MB of memory. The bigger problem is that the memory doesn't get released after the download completes. I'd love to enable my app users to download about 15K tiles since it would improve the user experience but I current limit it to avoid app crashes. Downloading 15K tiles worked just fine prior to iOS8 but has been broken since then. I spent about 80 hours working with Justin from Mapbox on the problem but we never found a solution. I'm hoping they will get to the bottom of it some day.

— Reply to this email directly or view it on GitHub https://github.com/mapbox/mapbox-ios-sdk/issues/599#issuecomment-79362554 .

bilby91 avatar Mar 13 '15 20:03 bilby91

That’s great news! Let me know if I can help test or at least buy you a 6 pack. -Ben

On Mar 13, 2015, at 2:43 PM, Martín Fernández [email protected] wrote:

Found the problem. NSURLConnection is leaking. Try using NSURLSession. I'm working on a PR for next weak. On vie, 13 mar 2015 at 17:38 elemprod [email protected] wrote:

I can confirm that I have the same problem using tiles served from Mapbox's servers. Downloading 7K tiles consumes over 200 MB of memory. The bigger problem is that the memory doesn't get released after the download completes. I'd love to enable my app users to download about 15K tiles since it would improve the user experience but I current limit it to avoid app crashes. Downloading 15K tiles worked just fine prior to iOS8 but has been broken since then. I spent about 80 hours working with Justin from Mapbox on the problem but we never found a solution. I'm hoping they will get to the bottom of it some day.

— Reply to this email directly or view it on GitHub https://github.com/mapbox/mapbox-ios-sdk/issues/599#issuecomment-79362554 .

— Reply to this email directly or view it on GitHub https://github.com/mapbox/mapbox-ios-sdk/issues/599#issuecomment-79369431.

elemprod avatar Mar 13 '15 20:03 elemprod

Hey @elemprod, I need some help! I have created this branch with the "fix" https://github.com/Moove-it/mapbox-ios-sdk/tree/nsurlconnection-leak.

NSURLSession performs better but it is still leaking some memory I guess. Maybe it is not related to NSURLConnection or NSURLSession and we are looking in the wrong place.

bilby91 avatar Mar 18 '15 16:03 bilby91

@elemprod had any change to try it out ?

bilby91 avatar Mar 19 '15 19:03 bilby91

Sorry, I've been slammed with a different project. I'll have time to try out a couple of things tomorrow. BTW I just verified that this problem does not exist on iOS7, it was introduced with iOS8. Maybe there is a clue there.

elemprod avatar Mar 19 '15 20:03 elemprod

I had some issues to test the current project in iOS 7 so I really don't know. My starting point for finding the issue was something I read that talked about NSURLConnection leaking on iOS 8.

Let me know what you think!

Thanks!

bilby91 avatar Mar 19 '15 20:03 bilby91

Has there been any movement on this issue? We'd love to enable our users to download bigger maps and consequently buy more tiles from Mapbox but the leaking background download code prevents us from doing so. Thanks!

elemprod avatar May 21 '15 17:05 elemprod

This is a huge problem: we are forced now to manually release all cached images when it reaches a certain limit, because the automatic cache deallocation does not work. In our app users spend a lot of time browsing the map all over the world, which, due to the lack of caching is a terrible experience. Every view tiles, excesively. Before completely going into GL, could we please try and fix this? Thanks!

trdavidson avatar May 30 '15 08:05 trdavidson