Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Memory use increases dramatically at high zooms, on iOS and Android #15022

Open
JesseCrocker opened this issue Jun 28, 2019 · 8 comments
Open
Assignees
Labels
Android Mapbox Maps SDK for Android Core The cross-platform C++ core, aka mbgl high priority iOS Mapbox Maps SDK for iOS performance Speed, stability, CPU usage, memory usage, or power usage support

Comments

@JesseCrocker
Copy link
Contributor

Platform: iOS and Android
Mapbox SDK version: iOS 5.1.0, Android 8.0.0

Steps to trigger behavior

  1. Load a map style with a source with a max zoom of 12
  2. Zoom in, 1 level at a time, until zoom 22.

Expected behavior

Memory use remains constant, or decrease as map is zoomed past the max zoom of source in loaded style.

Actual behavior

Memory use starts to increases when the map has been zoomed about 6 levels past the max zoom of the source. Each additional zoom level causes memory use to incerease ~1.5 more than it did for the previous level. The increase in memory from 21 to 22 is frequently enough to cause the app to get killed.

I'm able to reproduce this behavior with multiple styles, including Mapbox outdoors. But it seems to have the most impact on styles where the max zoom of the sources is lower.

Here's a graph of memory use on iOS with a source with a max zoom of 12, labeled to show zoom events.
Screen Shot 2019-06-26 at 2 37 21 PM

Here is a sample iOS project: https://github.com/JesseCrocker/Mapbox-gl-native-testcases/tree/vector-overzoom

Here's a gif showing the sample project, and a graph of memory use.
Jun-28-2019 06-30-12

I am a Mapbox enterprise customer.

@julianrex julianrex added Core The cross-platform C++ core, aka mbgl support iOS Mapbox Maps SDK for iOS labels Jun 28, 2019
@tmpsantos
Copy link
Contributor

@JesseCrocker thanks for reporting the issue with such a detailed analysis. I'm surprised that this is happening because the number if tiles on the map view is usually no bigger than a fixed number depending on the screen resolution and what adds to memory usage is the data density. After zoom level 16 I would expect memory usage to drop.

@bilaltawfic
Copy link

@tmpsantos I've stumbled across the same issue. Is there an ETA on when this might be resolved?

@tmpsantos
Copy link
Contributor

@bilaltawfic We will do our best to get started on this next week.

@tmpsantos
Copy link
Contributor

By next week I mean monday :-)

@bilaltawfic
Copy link

Amazing! Thanks!

@chloekraw chloekraw added the performance Speed, stability, CPU usage, memory usage, or power usage label Jul 18, 2019
@astojilj
Copy link
Contributor

Link to related work mapbox/mapbox-gl-js#1898

@zmiao
Copy link
Contributor

zmiao commented Jul 18, 2019

Thanks for the help from @alexshalamov.
We run the sample project with ios-5.1.0 and ios-4.7.0, the memory consumption behaviors are the same, also we compared the behaviors between gl-native and gl-js, the behavior of memory consumption peak are also the same, so I think that is not a regression.

In this case, the symbol layer source is line, and the label is rendered along the line. Before rendering the text label, Symbol Instance will be allocated for each anchor of the text label and a SymbolBucket will be created for holding all the SymbolInstances. The density of the label(number of anchors) is growing with regarding to the zoom level. Assuming zoom level change from 18 to 24, the number of the symbol instances will be increased by 2^6 times.

The behavior is as expected, but there could be obvious optimization after mapbox/mapbox-gl-js#1898 is done.

Another issue we found is the continuous memory growth in gl-native with regarding to symbol bucket. We are investigating it.

@zmiao
Copy link
Contributor

zmiao commented Jul 19, 2019

We found the continuous memory growth issue #15179 was probably introduced as a regression from the pull request #14669. But this memory growth would only happen when Debug information is enabled.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android Core The cross-platform C++ core, aka mbgl high priority iOS Mapbox Maps SDK for iOS performance Speed, stability, CPU usage, memory usage, or power usage support
Projects
None yet
Development

No branches or pull requests

7 participants