Annotation Type AutoreleasePool


@Target({METHOD,LOCAL_VARIABLE}) @Retention(SOURCE) public @interface AutoreleasePool
Annotation that indicates the translator should inject an autorelease pool around the method body. Only valid on methods that don't return anything.

Useful in high-level contexts to ensure that temporary objects allocated within the method or loop are deallocated.

Example usage:

// Temporary objects allocated during execution of this method will
// be deallocated upon returning from this method.
@AutoreleasePool
public void doWork() {
  ...
}

public void doWork(Iterable<Runnable> workToDo) {
  // Adding @AutoreleasePool on the loop variable causes a separate
  // autorelease pool to be attached to each loop iteration, clearing
  // up temporary objects after each iteration
  for (@AutoreleasePool Runnable item : workToDo) {
    item.run();
  }
}
Author:
Pankaj Kakkar