From 8fa646ca2d029165c24009c60d748a8915682866 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 27 Jun 2024 14:40:06 -0700 Subject: [PATCH 1/2] FIX: memory leak in RouteMapViewController Circular reference passed to escaping closure. --- MapboxNavigation/RouteMapViewController.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MapboxNavigation/RouteMapViewController.swift b/MapboxNavigation/RouteMapViewController.swift index 1157b6dc..3957dabd 100644 --- a/MapboxNavigation/RouteMapViewController.swift +++ b/MapboxNavigation/RouteMapViewController.swift @@ -89,7 +89,9 @@ class RouteMapViewController: UIViewController { self.navigationView.statusView.canChangeValue = self.routeController?.locationManager is SimulatedLocationManager guard let destination = self.route?.legs.last?.destination else { return } - self.populateName(for: destination, populated: { self.destination = $0 }) + self.populateName(for: destination, populated: { [weak self] waypoint in + self?.destination = waypoint + }) } } From 636ea928272fa02f9cd01104a66ef0a3b2838105 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 27 Jun 2024 14:46:15 -0700 Subject: [PATCH 2/2] FIX: memory leak in RouteMapViewController The old Timer API maintains a strong reference to `target`. --- MapboxNavigation/RouteMapViewController.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MapboxNavigation/RouteMapViewController.swift b/MapboxNavigation/RouteMapViewController.swift index 3957dabd..556a99de 100644 --- a/MapboxNavigation/RouteMapViewController.swift +++ b/MapboxNavigation/RouteMapViewController.swift @@ -891,7 +891,9 @@ private extension RouteMapViewController { func resetETATimer() { self.removeTimer() - self.updateETATimer = Timer.scheduledTimer(timeInterval: 30, target: self, selector: #selector(self.updateETA), userInfo: nil, repeats: true) + self.updateETATimer = Timer.scheduledTimer(withTimeInterval: 30, repeats: true) { [weak self] _ in + self?.updateETA() + } } func showRouteIfNeeded() {