I am having some very unfortunate behavior with my program working for a few actions and then suddenly it crashes without a decent bit of useful information. I've been looking into memory leaks and from the looks of it, I only have a couple of small ones. I tracked one of them down to this piece of code:
ItemListController is defined as such:
The exact line of the leak is:
If I comment/remove that line the leak goes away.
Can anyone think of a reason why that would cause a leak? It doesn't seem like I'm doing anything out of the ordinary...
Code:
if(self.itemListController == nil) {
ItemListController *controller = [[ItemListController alloc] init];
self.itemListController = controller;
[controller release];
}
NSMutableArray *itemArray = [[NSMutableArray alloc] initWithObjects:sword, shield, subligar, nil];
self.itemListController.items = itemArray;
[sword release];
[shield release];
[subligar release];
[itemArray release];
ItemListController is defined as such:
Code:
#import <UIKit/UIKit.h>
#import "Item.h"
@interface ItemListController : NSObject {
NSMutableArray *items;
Item *defaultItem;
}
@property (nonatomic, retain) NSMutableArray *items;
-(void)setDefaultItem:(Item *)item;
@end
The exact line of the leak is:
Code:
self.itemListController.items = itemArray;
Can anyone think of a reason why that would cause a leak? It doesn't seem like I'm doing anything out of the ordinary...