Advanced Swift: Memory Management

May 15 2019 · Video Course (22 mins) · Advanced

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.

5/5 3 Ratings

Version

  • Swift 5, iOS 12, Xcode 10

Introduction

1:51 Free

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

1

Weak

3:18

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

2

Unowned

1:57

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

3

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

4

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.

5

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

6

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

7

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

8

Conclusion

2:39

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

9

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

Contributors

Comments