What is the equivalent of @autoreleasepool in Swift?

Skotch picture Skotch · Jun 11, 2014 · Viewed 16.6k times · Source

In Swift, I notice there is no @autoreleasepool{} construct, although Swift does use ARC. What is the proper way to manage an autoreleasepool in Swift, or has it been removed for some reason?

Answer

Abhi Beckert picture Abhi Beckert · Jun 11, 2014

This is explained in detail in WWDC 2014 session video number 418 "Improving Your App with Instruments", which you can also download as a PDF.

But in short, the syntax is:

autoreleasepool {
  /* code */ 
}