user1121504
user1121504

Reputation: 73

iphone: autoreleasing an object multiple times

what happens if i retain an object multiple times. Then, will autoreleasing it once, delete it from the memory when the autorelease pool is drained; or do i have to autorelease it as many times as i retained it ?

Upvotes: 3

Views: 245

Answers (1)

Vladimir
Vladimir

Reputation: 170859

Autorelease schedules an object to be released once in some time in future (i.e. when current autorelease pool is drained). So if you retain an object several times you need to (auto)release it the same number of times to compensate that

Upvotes: 5

Related Questions