Question: Here's a common practice I see often (including from a very popular iPhone developer book)

In the .h file:

```
@interface SomeViewController : UIViewController
{
  UIImageView *imgView;
}

```

Somewhere in the .m file:

```
imgView = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen]
applicationFrame]];
[imgView setImage:[UIImage imageNamed:@"someimage.png"]];
[self addSubview:imgView];
[imgView release];

```

And later, we see this...

```
- (void) dealloc
{
  [imgView release];
  [super dealloc];

} 

```

Since imgView has a matching alloc and release, is the release of imgView in dealloc necessary? 

Where is the imgView retained by the addSubview call accounted for?

Answer: 
The code is incorrect. You'll end up releasing `imgView` after it's been deallocated.

In your .m file, you:

1. `alloc` it --> you own it
2. add it as a subview --> you and [the UIView owns it](http://developer.apple.com/iPhone/library/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instm/UIView/addSubview:)
3. `release` it --> you don't own it

Then in `dealloc`, you `release` imgView even though, as we established at step 3 above, you don't own it. When you call `[super dealloc]`, the view will release all of its subviews, and I imagine you'll get an exception.

If you want to keep an ivar of `imgView`, I suggest *not* calling `release` after you add it as a subview, and keep your `dealloc` the same. That way, even if `imgView` is at some point removed from the view hierarchy, you'll still have a valid reference to it.
The code is incorrect, you shouldn't be releasing it in the init method, just when dealloc is called (that's if you want to keep it as an ivar, you don't need to unless you need a pointer to it elsewhere since addSubview: will retain the view for you).

I believe the reason it's not actually crashing is because it's still being retained by the superclass (from the call to addSubview:), so when it's released in dealloc that's actually balanced out. The view probably removes itself from the superview when it's deallocated immediately afterwards, so when `[super dealloc]` is called it's not being over-released. That's my hunch, at lease.