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: 
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)
Did you try this: `UIImage *img = [[UIImage alloc] initWithData:data];` and you can release whenever you want.

EDIT:

Also if you try to release created object without alloc method, your app will crash, because you didnt alloc and you didnt say to memory "this place is mine !", then your app will autorelease your object.