Skip to content
This repository has been archived by the owner on May 9, 2018. It is now read-only.

Background caching memory growth #599

Open
bilby91 opened this issue Mar 6, 2015 · 10 comments
Open

Background caching memory growth #599

bilby91 opened this issue Mar 6, 2015 · 10 comments

Comments

@bilby91
Copy link

bilby91 commented Mar 6, 2015

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
Copy link
Author

bilby91 commented Mar 11, 2015

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.

@elemprod
Copy link

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.

@bilby91
Copy link
Author

bilby91 commented Mar 13, 2015

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
#599 (comment)
.

@elemprod
Copy link

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
#599 (comment)
.


Reply to this email directly or view it on GitHub #599 (comment).

@bilby91
Copy link
Author

bilby91 commented Mar 18, 2015

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
Copy link
Author

bilby91 commented Mar 19, 2015

@elemprod had any change to try it out ?

@elemprod
Copy link

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.

@bilby91
Copy link
Author

bilby91 commented Mar 19, 2015

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!

@elemprod
Copy link

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!

@trdavidson
Copy link

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!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants