Domanda di colloquio di Infosys

How do you manage memory in Swift, and how does ARC (Automatic Reference Counting) work?

Risposta di colloquio

Anonimo

27 feb 2025

Swift uses ARC (Automatic Reference Counting) to manage memory. It tracks object references and automatically deallocates objects when no references remain. To avoid retain cycles, especially with closures and delegates, I use [weak self] or unowned. I also regularly check for leaks using Instruments and the Memory Graph Debugger to keep the app memory-efficient.