Sitemap

Stop Forgetting ARC: Swift Memory Management in 5 Minutes

2 min readJan 24, 2026

--

ARC in Swift (Without Overthinking It)

Automatic Reference Counting (ARC) is Swift’s way of managing memory automatically.
Objects stay alive as long as someone needs them — and disappear when nobody does.

ARC Rule #1:
If at least one
strong reference exists, the object lives.

Press enter or click to view image in full size
Photo by Steve Johnson on Unsplash

How ARC Works (1-minute version)

Swift keeps a count of strong references to every object.

  • Count goes up → object stays in memory
  • Count goes to zero → object is deallocated

No manual memory cleanup. No guessing. Swift handles it.

The Only Three References You Need to Remember

1. Strong (default)

“I own you.”

  • Increases reference count
  • Keeps the object alive

🧠 Strong = Stays alive

2. Weak

“I know you, but I don’t own you.”

  • Does not increase reference count
  • Automatically becomes nil
  • Always optional

🧠 Weak = Will turn nil

3. Unowned

“I trust you’ll never disappear.”

  • Does not increase reference count
  • Never becomes nil
  • Crashes if object is gone

🧠 Unowned = Unsafe trust

4. The Real Problem: Strong Reference Cycles ☠️

When two objects strongly reference each other:

  • Reference count never reaches zero
  • Objects are never deallocated
  • Memory leak

💡 Fix:
Make one side weak or unowned

Every cycle needs a weak link.

When to Use What (Remember This)

ScenarioUseParent → ChildStrongChild → ParentWeakDelegatesWeakClosures capturing selfWeak / Unowned

Get Ajay Odedara’s stories in your inbox

Join Medium for free to get updates from this writer.

🧠 Golden Rule:
If two objects reference each other, both cannot be strong.

Why ARC Is Great

  • 🚀 Automatic memory cleanup
  • 🧼 Cleaner, safer code
  • 🛡 Fewer crashes and leaks

Final Thought

ARC is simple once you stop memorizing rules and remember one idea:

Objects live as long as someone needs them.

--

--

Ajay Odedara
Ajay Odedara

Written by Ajay Odedara

0 followers

iOS Engineer with 10+ years of experience. I write short blogs on iOS & cross-platform topics, focused on explaining concepts in simple, memorable language.