Tell me more ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

In Objective-C it seems that the opposite of alloc is release (which undoes the memory allocation that alloc did), and the opposite of init is dealloc (which undoes the instance initialization done by init). Wouldn't a better name for dealloc be uninit or deinit?

share|improve this question
1  
release doesn't undo the memory allocation. dealloc does that, but in NSObject. release merely triggers dealloc when the reference count reaches 0. – K.Steff Nov 10 '12 at 1:35

closed as not constructive by Walter, Bill, GlenH7, MainMa, ChrisF Nov 10 '12 at 10:48

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or specific expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, see the FAQ for guidance.

2 Answers

The opposite of alloc is dealloc while release is the direct opposite of retain.

More on dealloc on stackoverflow.

share|improve this answer
OK so it seems that dealloc does 2 jobs, namely to undo what was done in both alloc and init? – JoelFan Nov 9 '12 at 19:37

dealloc actually releases the memory held by an object. release just sends a message to an object to decrement its retain count; in calls dealloc when its retain count reaches 0.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.