Chapter    14

Memory Management and ARC

Memory management is part of a more general problem in programming called resource management. Every computer system has finite resources for a program to use. These include memory, open files, and network connections. If you use a resource, such as by opening a file, you need to clean up after yourself (in this case, by closing the file). If you keep on opening files but never close them, you’ll eventually run out of file capacity. Think about your public library. If everyone borrowed books but never returned them, eventually the library would close because it would have no more books.

Of course, when your program ends, the operating system reclaims the resources it used. But as long as your program is ...

Get Learn Swift on the Mac: For OS X and iOS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.