In Objective-C all objects can be released from memory using release function ?
Yes,You should release all objects,if you alloc/retain/copy the objects....
Objects are not necessarily cleared from memory when you call release. Also, it might be necessary to call special functions for Core Foundation objects (such as CGColorRef). In general, you have to call one release or autorelease for every alloc, retain or copy call you make on an object.
For more details, see Apple's memory management guide.
Not every object needs to be released. You should revise the memory management guidelines, this a comprehensive guide about memory management.
The gist of it is: if you obtained an object from a method with the word alloc
, new
or copy
in its name, then you need to release
it. You also need to balance each retain
with a release
or autorelease
.
release
only reduces an objects retain count, it does not necessarily deallocate it from memory. It is only deallocated when its retain count reaches 0.