Question: Can Anyone explain me the following image, that how can I do releasing within this block of code

![enter image description here](https://i.stack.imgur.com/nvRpU.jpg)

why there is issue when some having another object and you are releasing, like 

```
NSURL *url = [NSURL URLWithString:@"some_url_having_image_on_server"];
NSData *data = [[NSData alloc] initWithContentsOfURL:url];      
UIImage *image = [UIImage imageWithData:data];

```

How would I do release and explain the cases, and don't pass me links, just explain in your own programming skill, I really want to clear some concepts of memory management, they ever make me crazy :-(

Thanks In Advance

Answer: 
All Methods without an alloc are autoreleased. So the [UIImage imagedWithData:] will be automatically released at the end of the runloop.
Methods with `alloc`, `copy,`copyMutable`and`new` will return an object with a retain count of 1.
All other methods should return autoreleased object that you do not need to release unless you retain explicitly. This is so for all of apple object-c objects. 

example:

```
// need to be released:
NSString *temp = [[NSString alloc] init];
NSString *tempCopy = [temp copy];
NSString *newString [NSString new]; // which is the same are alloc, init.

[newstring release];
[tempCopy release];
[temp release];

```

Autoreleased objects: 

```
// You don not release:
NSString *temp = @"some string";
NSString *temp2 =[NSString string];

```

If you really want to learn the concepts than you should really read these:

* [Advanced Memory Management Programming Guide](https://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html#//apple_ref/doc/uid/20000994-BAJHFBGH)
* [Memory Management Programming Guide for Core Foundation](https://developer.apple.com/library/ios/#documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/CopyFunctions.html#//apple_ref/doc/uid/20001149-CJBEJBHH)