summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Maps.iOS/MapPool.cs
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@users.noreply.github.com>2017-01-12 21:43:57 (GMT)
committerJason Smith <jason.smith@xamarin.com>2017-01-12 21:43:57 (GMT)
commitba7b66b83a83328f56e0676efcff5d3c553ac6bf (patch)
tree0d77274282c801aaadd3954850703f21b3967285 /Xamarin.Forms.Maps.iOS/MapPool.cs
parentb6cb64e4930de9b16309f2d30c6bb0a2177048fd (diff)
downloadxamarin-forms-ba7b66b83a83328f56e0676efcff5d3c553ac6bf.zip
xamarin-forms-ba7b66b83a83328f56e0676efcff5d3c553ac6bf.tar.gz
xamarin-forms-ba7b66b83a83328f56e0676efcff5d3c553ac6bf.tar.bz2
Fix out-of-memory crashes on iOS when creating maps (#467)
* Pool map views on iOS 10 to avoid memory issues Clean up disposal implementation for map renderer, delegate * Enable 39489 test on iOS * Add missing XF Maps references * Add missing maps reference to Windows 8.1 project * Actually enable the test for iOS * Fix placement of Isolate override * Don't create a new control for ImageRenderer if NewElement is null * Reverting fixes to ViewRenderer Dispose; have to fix that in a separate PR
Diffstat (limited to 'Xamarin.Forms.Maps.iOS/MapPool.cs')
-rw-r--r--Xamarin.Forms.Maps.iOS/MapPool.cs25
1 files changed, 25 insertions, 0 deletions
diff --git a/Xamarin.Forms.Maps.iOS/MapPool.cs b/Xamarin.Forms.Maps.iOS/MapPool.cs
new file mode 100644
index 0000000..dc8a9c4
--- /dev/null
+++ b/Xamarin.Forms.Maps.iOS/MapPool.cs
@@ -0,0 +1,25 @@
+using System.Collections.Concurrent;
+using MapKit;
+
+namespace Xamarin.Forms.Maps.iOS
+{
+ // A static pool of MKMapView instances we can reuse
+ internal class MapPool
+ {
+ static MapPool s_instance;
+ public static MapPool Instance => s_instance ?? (s_instance = new MapPool());
+
+ internal readonly ConcurrentQueue<MKMapView> Maps = new ConcurrentQueue<MKMapView>();
+
+ public static void Add(MKMapView mapView)
+ {
+ Instance.Maps.Enqueue(mapView);
+ }
+
+ public static MKMapView Get()
+ {
+ MKMapView mapView;
+ return Instance.Maps.TryDequeue(out mapView) ? mapView : null;
+ }
+ }
+} \ No newline at end of file