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.
Release in init is incorrect. 

You mentioned "common practice" and an un-named book. I suggest looking at the canonical examples from Apple: ViewTransitions is a good example for this case (and 2 views to boot ;) 

<http://developer.apple.com/iphone/library/samplecode/ViewTransitions/index.html>