I have seen many questions / answers about memory leaks in NSDateFormatter, but no one helps me determine what causes a memory leak in my application. Here is my code:
- (id)init { if ((self = [super init])) { items = [[NSMutableArray alloc] init]; events = [[NSMutableArray alloc] init]; buffer = [[NSMutableData alloc] init]; format = [[NSDateFormatter alloc] init]; lastFromDate = @""; } return self; } - (void)presentingDatesFrom:(NSDate *)fromDate to:(NSDate *)toDate delegate:(id<KalDataSourceCallbacks>)delegate { [format setTimeZone:[NSTimeZone systemTimeZone]]; [format setDateFormat:@"MM/dd/yyyy"]; NSString *stringFromDate = [NSString stringWithString:[format stringFromDate:fromDate]]; NSString *stringToDate = [NSString stringWithString:[format stringFromDate:toDate]]; NSLog(@"From date: %@, To date: %@", stringFromDate, stringToDate); [self didDatesChange:stringFromDate]; if (dataReady) { [callback loadedDataSource:self]; return; } callback = delegate; [self retrieveEventData:stringFromDate to:stringToDate]; } - (void)dealloc { [items release]; [events release]; [buffer release]; [lastFromDate release]; [format release]; [super dealloc]; }
When I run Profile → Leaks, I get a memory leak every time a function is called on a line
NSString *stringFromDate = [NSString stringWithString:[format stringFromDate:fromDate]];
Can someone explain what could be? thanks mike
source share