summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Loer <chris.loer@gmail.com>2018-02-13 14:33:07 -0800
committerChris Loer <chris.loer@gmail.com>2018-02-13 14:33:07 -0800
commit52957fd8c47c4016231839631b4b8a76a76b73f9 (patch)
treea9a83578def33c92439bcf63db849bdbc5312708
parentb4fb4f6cc4e5edeaa6538250f3b81f92f53bf529 (diff)
downloadqtlocation-mapboxgl-upstream/release-more-memory.tar.gz
[ios,macos] Release cached tiles on entering background.upstream/release-more-memory
Retain current render tiles for fast restart. Waiting for a memory warning doesn't work because we can't make GL release calls once we're in the background.
-rw-r--r--platform/ios/src/MGLMapView.mm7
1 files changed, 7 insertions, 0 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 31eac056e5..66967c3696 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -1148,6 +1148,13 @@ public:
- (void)sleepGL:(__unused NSNotification *)notification
{
MGLAssertIsMainThread();
+
+ // Ideally we would wait until we actually received a memory warning but the bulk of the memory
+ // we have to release is tied up in GL buffers that we can't touch once we're in the background.
+ // Compromise position: release everything but currently rendering tiles
+ // A possible improvement would be to store a copy of the GL buffers that we could use to rapidly
+ // restart, but that we could also discard in response to a memory warning.
+ _rendererFrontend->onLowMemory();
if ( ! self.dormant)
{