


Memory management is a core part of building reliable iOS features in the American Express Global Business Travel mobile app. Interviewers ask this to assess whether you can prevent leaks, avoid retain cycles, and reason about object lifetimes in Swift.
Explain how memory is managed in a Swift app. Your answer should cover:
weak vs unowned references, and the trade-offs.Go beyond a high-level definition. The interviewer expects you to explain object ownership, deallocation behavior, common leak patterns in UIKit/SwiftUI-style code, and how you would diagnose and prevent memory issues in production code.
Swift uses ARC to track how many strong references point to an object. When the strong reference count reaches zero, the object is deallocated automatically.
class TripViewModel {}
var vm: TripViewModel? = TripViewModel()
vm = nil # object can be deallocated
A strong reference cycle happens when two objects keep strong references to each other, so neither reference count reaches zero. This causes a memory leak even if the objects are no longer needed.
class A { var b: B? }
class B { var a: A? }
A weak reference does not increase the reference count of the referenced object. It is automatically set to nil when the object is deallocated, so it must be optional.
class Child {
weak var parent: Parent?
}
An unowned reference also does not increase the reference count, but it assumes the referenced object will still exist when accessed. It is not optional and will crash if accessed after deallocation.
class CreditCard {
unowned let customer: Customer
init(customer: Customer) {
self.customer = customer
}
}
Closures capture referenced objects strongly by default. If a closure is retained by an object and also captures that object, it can create a retain cycle unless a capture list such as [weak self] is used.
service.load { [weak self] result in
self?.handle(result)
}