AutoreleasePool
Stay organized with collections
Save and categorize content based on your preferences.
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();
}
}
Inherited Method Summary
From interface
java.lang.annotation.Annotation
abstract
Class<? extends Annotation>
|
annotationType()
|
abstract
boolean
|
equals(Object arg0)
|
abstract
int
|
hashCode()
|
abstract
String
|
toString()
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["`@AutoreleasePool` annotation triggers the translator to insert an autorelease pool around a method's body, ensuring temporary objects are deallocated."],["It's applicable to void methods and helps manage temporary object allocation in high-level contexts or loops."],["Using `@AutoreleasePool` on a loop variable creates a separate autorelease pool for each iteration, enhancing memory management within the loop."],["This annotation is inherited from `java.lang.annotation.Annotation` and includes methods like `annotationType()`, `equals()`, `hashCode()`, and `toString()`."]]],[]]