I use xcode 4.2 and this use ARC (Automatic Reference Counting).
This is not memory leak, because ARC send message of ‘release’:
NSNumber *xy = [[NSNumber alloc] init];
But it’s possible to create memory leaks with this:
char *oldString = "Old String";
char newStrig = strdup(oldString);
I wanted to know that other types of memory leaks can be made?
(If is possible without using C or C++)
ARC only applies to Cocoa memory management. If you are casting between Cocoa and CoreFoundation for the toll-free bridge objects there are macros to transfer the memory-management.
You can leak memory in C, you can leak Core Foundation memory, and the static analyser helps with finding those.
ARC doesn’t do away with memory management completely. It removes the need to manage memory for Cocoa objects and in some cases (because it can optimise away some
retainreleasecalls) is more efficient in managing memory, but you still need to understand memory management for Core Foundation objects, and for C memory.You also need to understand Cocoa memory management to understand when to use
strong,weak, orcopyproperties, and when to useBlock_copy()andBlock_release()on blocks, even though blocks are Cocoa objects and in most cases the correct memory management is handled for you with ARC.Again; ARC doesn’t do away with memory management. It simplifies it, and reduces the amount of code you have to write, but you still have to understand what is being done for you behind the scenes, and when you need to manage your own memory.