Pergunta de entrevista da empresa Infosys

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

Resposta da entrevista

Sigiloso

27 de fev. de 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.