According to the static analyzer if we have the following property:

```
@property (retain, nonatomic) SomeObject * object;

```

and then we assign the property like so: 

```
self.object = [SomeObject alloc] init];

```

a leak occurs. This makes sense because the alloc init adds +1 to the retain count and then the retaining property also increments the retain count. What is the best solution here? typically I just add an autorelease like so:

```
self.object = [[SomeObject alloc] init] autorelease];

```

But sometimes this creates problems for me and I end up over releasing the object causing my app to crash. I don't have any specific examples right now but I remember I had to take out some autoreleases cause of the application crashing. Is there something I am missing here?

EDIT: I have a concrete example now of the issue I was running into.

```
    NSMutableArray *newData = [NSMutableArray array];

    //If this is true then we are showing all of the items in that level of hierarchy and do not need to show the summary button.
    if (!(contextID.count >= 1 && [[contextID objectAtIndex:contextID.count - 1] isEqual:[NSNull null]]) && contextID.count != 0)
    {
        GeographyPickerItem * firstItem = [[GeographyPickerItem alloc] init];

        firstItem.primaryString = [NSString stringWithString:@"Summary"];
        firstItem.subString = [NSString stringWithString:@""];
        firstItem.isSummaryItem = YES;

        [newData addObject:firstItem];
        [firstItem release]; //TODO: Figure out why this is causing EXC_BAD_ACCESS errors
    }

    self.hierData = newData;

```

The code above is in the init method of a viewcontroller. HierData is a retained property, which is released in the viewControllers dealloc method. GeographyPickerItem retains the two strings, primaryString and subString and releases them in its own dealloc method. My application crashes (sometimes) when the viewControllers are de-alloced following a pop off of a navigation controller. It crashes with a EXC\_BAD\_ACCESS signal in the dealloc method of GeographyPickerItem (either on [substring release] or [primaryString release]).

I don't understand why this is happening because I believe I am following proper memory management guidelines. If I comment out firstItem release everything is fine.