Dealing with leaks and growing real memory issues in Cocoa apps

One of the most scary parts of iOS and Mac OS development has been the issue of managing memory, allocs, retain counts, releases and all that stuff. 

Being a developer who has started building apps for the Mac after learning Objective-C and its fundamentals with the iOS SDK, cocoa’s automatic memory management and garbage collection always made me feel weird and insecure about the stability of the apps I build.

To feel more confident with my code while building Mac OS apps, I personally prefer to remove support for garbage collection in my app and handle all memory allocations and releases manually. 

To do this, in Xcode, just open up the inspector on your project’s target (CMD + I), go to the build tab, and set the value of “Objective-C Garbage Collection” setting to “Unsupported” 

GCC_ENABLE_OBJC_GC = unsupported

Other than that, not to have headaches about leaks and app crashes related to bad memory usages, I recommend you to read and learn about the fundamentals of memory management in Objective-C. Here are a few good blog posts that may help.

InterfaceLab - Memory Management for Lazy People

Matt Patanaude - Memory Management in Cocoa

Apple Developer Docs - Memory Management

Apple Developer Docs - Introduction to Garbage Collection

Finally,

May not the leaks be with you :)