Requires a pro subscription Pro

Advanced Swift: Memory Management

Memory management works like magic most of the time - until it doesn't. Find out what you need to watch out for in this course. By Ray Fix.

Login to leave a rating/review
Save for later
Share

Learning path

This is part of the Advanced Swift learning path. View Path.

Who is this for?

This course is for developers interested in getting a deeper understanding of the Swift language. It expects you to be comfortable with the basic syntax of Swift and to have perhaps written an app or two. You should be familiar with basic types in the Swift standard library.

Covered concepts

This course focuses on:

  • Memory
  • weak
  • Closure captures
  • unowned
  • Function types

1
Toggle description

Automatic memory management in Swift is very low overhead and efficient but requires your cooperation for it to work right.

Weak 3:18
Toggle description

In this video we will look at how resource problems can occur, and how we can fix them using weak.

Unowned 1:57
Toggle description

The unowned keyword hints the compiler that an object should not participate in reference counting. Sometimes it is the best solution.

Toggle description

In this video we've got a memory management challenge for you! This time, try adding weak to fix the leak.

Toggle description

Functions are reference types and can lead to reference cycles. Learn to break the cycle by controlling how references are copied into a closure's environment.

Toggle description

Swift has an elegant mechanism to let you prevent reference cycles from happening: the capture list.

Toggle description

Use closure captures to prevent leaks. In this video, let's do the strong-weak dance and other jigs.

Toggle description

In this challenge you will find yet another example of leaky code. Fix it with your new set of tools.

Conclusion 2:39
Toggle description

Knowing relationships between the objects in your system is the key to creating a leak free system.