Possible Duplicate:
What are the differences between free, dealloc, release, and autorelease?
I want to get rid of my allocated memory used in my app. I know I need to use release but what is the difference between free() and release? Are they the same?
free()is part of the C standard library, so it’s a function. It immediately frees the allocated memory obtained usingmalloc(), so it must be passed a pointer that is allocated bymalloc(), else it invokes undefined behavior.- releaseis a method (as opposed to a function) of theNSObjectclass. It does not immediately free memory; it only decrements an object’s reference count by one. It then also checks for it being 0 – if it is zero, it invokes- dealloc(which is usually overridden by a subclass to free memory allocated by the constructor method,- initorfree()memory allocated bymalloc()).So they are not the same at all, do not even attempt to use them interchangeably!