[Objective-C] Memory management
Managing object memory is a matter of performance; if an application doesn’t free unneeded objects, its memory footprint grows and performance suffers and sometimes your application crash. THAT'S BAD:(
Memory management in a Cocoa application that doesn’t use garbage collection is based on a reference counting model. OK lets see a sample
image from oficial cocoa docI'll try help you to explicitly manage memory in Objective-C code with simple tips
- If you are not the creator of an object, but want to ensure it stays in memory for you to use, you can express an ownership interest in it.
- Related method: retain
- If you own an object, either by creating it or expressing an ownership interest, you are responsible for releasing it when you no longer need it.
- Related methods: release, autorelease
- Conversely, if you are not the creator of an object and have not expressed an ownership interest, you must not release it.