Swift Combine: WARNING!!! How to Avoid Memory Leaks!

Memory Leak Scenario with Combine

Memory Leak Scenario

What causes Memory Leak

The main source of problem

Solution # 1

Replace assign with `sink` and remove strong reference
Solution 1

Solution # 2

@Published and assign(to:)
Solution 2


  1. sink directly and avoid strong reference
  2. Use @Published annotation. And assign value with assign(to:) instead of assign(to:,on:)



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
KD Knowledge Diet

KD Knowledge Diet


Software Engineer, Mobile Developer living in Seoul. I hate people using difficult words. Why not using simple words? Keep It Simple Stupid!