Memory management is often considered difficult to understand, but when you break it down, you can see that it is relatively straightforward. In this chapter, we have seen that all data in a computer is either stored in the file system that is a slow permanent storage, or in memory, which is a fast but temporary location. The file system is used as a backup to memory, slowing down the computer greatly, so we as programmers want to minimize the amount of memory we are ever using at one time.
We saw that in Swift there are value types and reference types. These concepts are critical to understanding how you can reduce memory usage and eliminate memory leaks. Memory leaks are created when an object has a strong reference to itself, maybe through a third party, which is called a strong reference cycle. We must also be careful that we keep at least one strong reference to every object we want to stay around or we may lose it prematurely.
With practice programming, you will get better with both preventing and fixing memory problems. You will write streamlined apps that keep your users' computers running smoothly.
We are now ready to move on to the last feature of Swift that we will discuss before we get into the more artful side of computer programming called error handling.