free()
is a C function that you use to dispose of no longer needed memory you obtained through malloc()
or other function that is documented to require free() to deallocate its memory e.g. strdup()
.
-dealloc
is an Objective-C selector that is sent by the Objective-C runtime to an object when the object is no longer owned by any part of the application.
-release
is the selector you send to an object to indicate that you are relinquishing ownership of that object. Once an object is not owned by anybody, it is sent the -dealloc
message by the runtime.
-autorelease
is a selector you send to an object to indicate you are relinquishing ownership of the object. However if nobody now owns the object the final -dealloc
will be deferred until some unspecified later point. In fact, what you are really doing is transferring your ownership to an autorelease pool which will then release it when it is itself released (or drained).
You must never send -dealloc
to an object except to super
in the object's own -dealloc
method.