---
title: "What happens when you call autorelease on an object?"  
description: "What happens when you call autorelease on an object?"  
author: "Anonymous User"  
published: 2015-07-28  
updated: 2020-09-23  
canonical: https://www.mindstick.com/interview/2739/what-happens-when-you-call-autorelease-on-an-object  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 2 minutes  

---

# What happens when you call autorelease on an object?

\

**When you** send a autorelease message to an object, its retain count is decremented by 1 at some stage in the future. The object is added to an autorelease pool on the current thread.

\

**The main thread** loop creates an autorelease pool at the beginning of the function, and release it at the end. This establishes a pool for the lifetime of the task. However, this also means that any autoreleased objects created during the lifetime of the task are not disposed of until the task completes. This may lead to the taskʼs memory footprint increasing unnecessarily. You can also consider creating pools with a narrower scope or use NSOperationQueue with itʼs own autorelease pool. (Also important – You only release or autorelease objects you own.)

## Answers

### Answer by Anonymous User

\

**When you** send a autorelease message to an object, its retain count is decremented by 1 at some stage in the future. The object is added to an autorelease pool on the current thread.

\

**The main thread** loop creates an autorelease pool at the beginning of the function, and release it at the end. This establishes a pool for the lifetime of the task. However, this also means that any autoreleased objects created during the lifetime of the task are not disposed of until the task completes. This may lead to the taskʼs memory footprint increasing unnecessarily. You can also consider creating pools with a narrower scope or use NSOperationQueue with itʼs own autorelease pool. (Also important – You only release or autorelease objects you own.)


---

Original Source: https://www.mindstick.com/interview/2739/what-happens-when-you-call-autorelease-on-an-object

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
